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(); } mPopupTipsPanel.SetText(txt, color); } void OnEnable() { } public void SetText(string txt, Color color) { mAnimator = mPopupTipsPanel.GetComponent(); 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); } }