XMB 主菜单Item选中动画实现

This commit is contained in:
ALIENJACK\alien 2024-08-16 10:53:43 +08:00
parent bb9ddfb22c
commit 5467ecb012
3 changed files with 13 additions and 22 deletions

View File

@ -84,7 +84,6 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1998281097548910301} - component: {fileID: 1998281097548910301}
- component: {fileID: 8083619837431842572}
- component: {fileID: 2502609279043838113} - component: {fileID: 2502609279043838113}
- component: {fileID: 5700455559359757662} - component: {fileID: 5700455559359757662}
m_Layer: 5 m_Layer: 5
@ -114,21 +113,6 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 203} m_SizeDelta: {x: 200, y: 203}
m_Pivot: {x: 0, y: 0.5} m_Pivot: {x: 0, y: 0.5}
--- !u!111 &8083619837431842572
Animation:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3189920797946144379}
m_Enabled: 1
serializedVersion: 3
m_Animation: {fileID: 0}
m_Animations: []
m_WrapMode: 0
m_PlayAutomatically: 1
m_AnimatePhysics: 0
m_CullingType: 0
--- !u!114 &2502609279043838113 --- !u!114 &2502609279043838113
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -144,6 +128,8 @@ MonoBehaviour:
Icon: {fileID: 7555299022933968962} Icon: {fileID: 7555299022933968962}
Txt: {fileID: 991446423622995247} Txt: {fileID: 991446423622995247}
Root: {fileID: 8754483333502849411} Root: {fileID: 8754483333502849411}
SelectScale: 1
UnSelectScale: 0.85
--- !u!114 &5700455559359757662 --- !u!114 &5700455559359757662
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -17,10 +17,6 @@ namespace AxibugEmuOnline.Client.UI
[SerializeField] [SerializeField]
List<MainMenuData> MenuSetting; List<MainMenuData> MenuSetting;
[SerializeField] [SerializeField]
float SelectScale = 1f;
[SerializeField]
float UnSelectScale = 0.85f;
[SerializeField]
float HoriRollSpd = 1f; float HoriRollSpd = 1f;
private RectTransform groupRootRect => GroupRoot.transform as RectTransform; private RectTransform groupRootRect => GroupRoot.transform as RectTransform;
@ -66,7 +62,7 @@ namespace AxibugEmuOnline.Client.UI
private void SetSelectProgress(MenuItem item, float selectProg) private void SetSelectProgress(MenuItem item, float selectProg)
{ {
item.Root.localScale = Vector3.one * Mathf.Lerp(UnSelectScale, SelectScale, selectProg); item.ControlSelectProgress(selectProg);
} }
private void Start() private void Start()
@ -77,6 +73,7 @@ namespace AxibugEmuOnline.Client.UI
m_runtimeMenuUI.Add(child.GetComponent<MenuItem>()); m_runtimeMenuUI.Add(child.GetComponent<MenuItem>());
} }
Canvas.ForceUpdateCanvases();
SelectIndex = 0; SelectIndex = 0;
} }

View File

@ -9,7 +9,11 @@ namespace AxibugEmuOnline.Client.UI
Image Icon; Image Icon;
[SerializeField] [SerializeField]
Text Txt; Text Txt;
public Transform Root; [SerializeField]
Transform Root;
public float SelectScale = 1f;
public float UnSelectScale = 0.85f;
public RectTransform Rect => transform as RectTransform; public RectTransform Rect => transform as RectTransform;
@ -21,7 +25,11 @@ namespace AxibugEmuOnline.Client.UI
public void ControlSelectProgress(float progress) public void ControlSelectProgress(float progress)
{ {
var temp = Txt.color;
temp.a = progress;
Txt.color = temp;
Root.localScale = Vector3.one * Mathf.Lerp(UnSelectScale, SelectScale, progress);
} }
} }
} }