using UnityEngine; using UnityEngine.UI; using System; using System.Collections; public class HudText : Regist { #region 变量 public Text Text { get { if (Text_ == null) { Text_ = GetComponent(); } return Text_; } set { Text_ = value; } } public Text Text_; public float Speed; public float StayTimer; public bool Lock; #endregion public override bool RegistImmed() { if (base.RegistImmed()) { return true; } enabled = true; return false; } private void FixedUpdate() { StayTimer -= Time.fixedDeltaTime; if (StayTimer < 0) { if (!Lock) { Lock = true; Text.TweenForCG(); } transform.position += new Vector3(0, Speed * Time.fixedDeltaTime, 0); } } public void Show(string str, Color color, int size, float speed, float time, float stay) { Text.text = str; Text.color = color; Text.fontSize = size; Lock = false; Speed = speed; StayTimer = stay; TweenCG tween = Text.CreateTweenCG(1, 0, time, true, true, Curve.EaseOutQuad); tween.CanvasGroup.alpha = 1; tween.AddEventOnetime ( EventType.ForwardFinish, () => { ManaReso.Save(gameObject); } ); } }