123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 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<Text>();
- }
- return Text_;
- }
- set { Text_ = value; }
- }
- public Outline Outline
- {
- get
- {
- if (Outline_ == null)
- {
- Outline_ = GetComponent<Outline>();
- }
- 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<TextPlus>();
- 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();
- }
- }
|