Files
2026-05-26 16:15:54 +08:00

65 lines
1.2 KiB
C#

using UnityEngine;
using UnityEngine.UI;
public class StarItem : MonoBehaviour
{
public Image[] Star;
public Animation ani;
//private void Reset()
//{
// Awake();
//}
private void Awake()
{
ani = GetComponent<Animation>();
int count = transform.childCount;
Star = new Image[count];
for (int i = 0; i < count; i++)
{
Star[i] = transform.GetChild(i).GetComponent<Image>();
}
}
public void SetStar(int index)
{
for (int i = 0; i < Star.Length; i++)
{
Star[i].gameObject.SetActive(index == i + 1);
}
}
public void PlayAni()
{
if (ani)
{
ani.Play("star_enhance");
}
}
public void Hide()
{
CanvasGroup cg = GetComponent<CanvasGroup>();
if (cg)
{
cg.alpha = 0;
}
}
public void PlayShow()
{
CanvasGroup cg = GetComponent<CanvasGroup>();
if (cg)
{
cg.alpha = 1;
}
if (ani)
{
ani.Play("star_show");
}
}
public void PlayHuXi()
{
if (ani)
{
ani.Play("star_huxi");
}
}
}