using UnityEngine; using UnityEngine.UI; public class StarItem : MonoBehaviour { public Image[] Star; public Animation ani; //private void Reset() //{ // Awake(); //} private void Awake() { ani = GetComponent(); int count = transform.childCount; Star = new Image[count]; for (int i = 0; i < count; i++) { Star[i] = transform.GetChild(i).GetComponent(); } } 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(); if (cg) { cg.alpha = 0; } } public void PlayShow() { CanvasGroup cg = GetComponent(); if (cg) { cg.alpha = 1; } if (ani) { ani.Play("star_show"); } } public void PlayHuXi() { if (ani) { ani.Play("star_huxi"); } } }