using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class HudTextPlus : MonoBehaviour { #region 变量 public Text Text { get { if (Text_ == null) { Text_ = GetComponent(); } return Text_; } set { Text_ = value; } } public Outline Outline { get { if (Outline_ == null) { Outline_ = GetComponent(); } return Outline_; } set { Outline_ = value; } } public Text Text_; public Outline Outline_; public float Speed; public Mode MoveMode; public Vector3 Direction; #endregion public enum Mode { Position, Direction, } public void Update() { if (MoveMode == Mode.Direction) { transform.position += Direction * Speed * Time.deltaTime; } } public void SetTween(float time, Color origin, Color dest) { TweenRoot tween = Text.CreateTweenGra(origin, dest, time, false, false, Curve.EaseOutQuad); tween.StartForward(); tween.OnForwardFinish = () => { ResourceManager.Save(gameObject); }; TextPlus textPlus = Text.GetComponent(); if (textPlus != null) { if (textPlus.ImagePlus.Draw) { Color color = textPlus.ImagePlus.color; textPlus.ImagePlus.CreateTweenGra(color*origin, color*dest, time, true, true, Curve.EaseOutQuad); } } } public void SetOutline(Color color, Vector2 size) { Outline.effectColor = color; Outline.effectDistance = size; } public void SetDirection(Vector3 direction) { Direction = direction; } public void Show(string str, int size, float speed) { MoveMode = Mode.Direction; Outline.enabled = false; Text.text = str; Text.color = Color.white; Text.fontSize = size; Speed = speed; Direction = Vector3.up; } public void Show(string str, int size, float time, Vector3 dest) { MoveMode = Mode.Position; Outline.enabled = false; Text.text = str; Text.color = Color.white; Text.fontSize = size; Direction = Vector3.up; TweenRoot tween = Text.CreateTweenVec2D(dest, time, false, true, true, Curve.EaseOutQuad); tween.StartForward(); } public void Show(string str, int size, float time, Vector3 origin, Vector3 dest) { MoveMode = Mode.Position; Outline.enabled = false; Text.text = str; Text.fontSize = size; Direction = Vector3.up; TweenRoot tween = Text.CreateTweenVec2D(origin, dest, time, false, true, true, Curve.EaseOutQuad); tween.StartForward(); } }