using UnityEngine; using UnityEngine.UI; using vnxbqy.UI; public class TipController : MonoBehaviour { [HideInInspector] public Text text; [HideInInspector] public UIAlphaTween alphaTween; [HideInInspector] public RectTransform rectTransform; [HideInInspector] public bool isFadeOut; private bool isPlaying; private void Awake() { text = transform.Find("Text").GetComponent(); alphaTween = GetComponent(); rectTransform = GetComponent(); } public void DoMove(Vector2 delta) { text.rectTransform.anchoredPosition += delta; } public void Init(string content) { gameObject.SetActive(true); alphaTween.enabled = true; text.text = content; isFadeOut = false; isPlaying = false; alphaTween.SetStartState(); //Debug.Log("init...."); } public void Play() { if (isPlaying) { return; } alphaTween.Play(OnEnd); isPlaying = true; } public void Recyle() { gameObject.SetActive(false); enabled = false; alphaTween.StopAllCoroutines(); alphaTween.SetStartState(); //Debug.Log("Recyle...."); } void OnEnd() { isFadeOut = true; //Debug.Log("fadeout...."); } }