AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/UI/MenuItem.cs

36 lines
866 B
C#
Raw Normal View History

using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client.UI
{
public class MenuItem : MonoBehaviour
{
[SerializeField]
Image Icon;
[SerializeField]
Text Txt;
2024-08-16 10:53:43 +08:00
[SerializeField]
Transform Root;
public float SelectScale = 1f;
public float UnSelectScale = 0.85f;
public RectTransform Rect => transform as RectTransform;
public void SetData(MainMenuData data)
{
Icon.sprite = data.Icon;
Txt.text = data.Name;
}
public void ControlSelectProgress(float progress)
{
2024-08-16 10:53:43 +08:00
var temp = Txt.color;
temp.a = progress;
Txt.color = temp;
2024-08-16 10:53:43 +08:00
Root.localScale = Vector3.one * Mathf.Lerp(UnSelectScale, SelectScale, progress);
}
}
}