12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class ManaMessage : MonoBehaviour
- {
- #region 变量
- private static float StayTimer;
- private static Text MessageLab;
- #endregion
- private void Awake()
- {
- MessageLab = ManaReso.Get<Text>("Message");
- }
- private void FixedUpdate()
- {
- if (MessageLab.color.a > 0)
- {
- StayTimer -= Time.fixedDeltaTime;
- if (StayTimer > 0)
- {
- return;
- }
- MessageLab.SetAlpha(Mathf.Lerp(MessageLab.color.a, 0, Time.fixedDeltaTime));
- if (MessageLab.color.a <= 0.05f)
- {
- MessageLab.SetAlpha(0);
- }
- }
- }
- public static void Show(string message, float stayTime)
- {
- MessageLab.text = message;
- MessageLab.SetAlpha(1);
- StayTimer = stayTime;
- }
- }
|