备份CatanBuilding瘦身独立工程
This commit is contained in:
64
Assets/Scripts/UI/Rod/StarItem.cs
Normal file
64
Assets/Scripts/UI/Rod/StarItem.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user