chicken_dy/Assets/Scripts/UI/PopupTipsPanel.cs

62 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PopupTipsPanel : MonoBehaviour
{
public Text tipsText;
Animator mAnimator;
private static PopupTipsPanel mPopupTipsPanel;
public static void PopupTips(string txt)
{
Debug.Log("Show PopTips : " + txt);
PopupTips(txt, Color.white);
}
public static void PopupTips(string txt, Color color)
{
if (mPopupTipsPanel==null)
{
GameObject obj = Resources.Load("CommonView/UI/Prefabs/PopupTipsPanel") as GameObject;
mPopupTipsPanel = GameObject.Instantiate(obj).GetComponent<PopupTipsPanel>();
}
mPopupTipsPanel.SetText(txt, color);
}
void OnEnable()
{
}
public void SetText(string txt, Color color)
{
mAnimator = mPopupTipsPanel.GetComponent<Animator>();
if (mAnimator != null)
{
mAnimator.Play("NoState");
if (IsInvoking("OpenAnimator"))
{
CancelInvoke("OpenAnimator");
}
Invoke("OpenAnimator", 1.0f);
}
tipsText.color = color;
tipsText.text = txt;
}
void OpenAnimator()
{
mAnimator.Play("outtips");
}
public void DestroyTips()
{
mPopupTipsPanel = null;
Debug.Log("DestroyTips");
Destroy(gameObject);
}
}