using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG; using DG.Tweening; public class Fluter : MonoBehaviour { /// /// 生命周期时间 /// public float liveTime; /// /// 当前运行时间 /// private float _runTime; private bool _isEnable = false; /// /// 显示内容 /// private string _content = ""; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (!_isEnable) { return; } this._runTime += Time.deltaTime; if (this._runTime > this.liveTime) { FluterManager.Instance.RemoveFluter(this); GameObject.Destroy(this.gameObject); } } /// /// 重设内容 时间恢复 /// /// public void RestContent(string str) { this._content = str; this.GetComponent().text = this._content; this.Play(); } public void Play() { this._runTime = 0; Vector3 targetPos = this.transform.position; targetPos.x += Random.Range(-100, 100); targetPos.y += 100; this.transform.DOMove(targetPos, 1); Color color = Color.white; color.a = 0.3f; this.GetComponent().DOColor(color, 2); this._isEnable = true; } }