12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Collections;
- public class HudText : Regist
- {
- #region 变量
- public Text Text
- {
- get
- {
- if (Text_ == null)
- {
- Text_ = GetComponent<Text>();
- }
- return Text_;
- }
- set { Text_ = value; }
- }
- public Text Text_;
- public float Speed;
- public float StayTimer;
- public bool Lock;
- #endregion
- public override bool InitAtOnce()
- {
- if (base.InitAtOnce())
- {
- return true;
- }
- enabled = true;
- return false;
- }
- private void Update()
- {
- StayTimer -= Time.deltaTime;
- if (StayTimer < 0)
- {
- if (!Lock)
- {
- Lock = true;
- Text.TweenForCG();
- }
- transform.position += new Vector3(0, Speed * Time.deltaTime, 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,
- () =>
- {
- ResourceManager.Save(gameObject);
- }
- );
- }
- }
|