12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- namespace LoyalSoftSDK
- {
- public class MessagePanel : BaseUIForm
- {
- private Text messageText;
- private Animator animator;
- // Use this for initialization
- private int showTime;
- private DateTime disTime;
- private bool isEnd = false;
- public override void Init()
- {
- curUIType = UIType.Loading;
- messageText= this.transform.Find("BackPanel/Text").gameObject.GetComponent<Text>();
- animator = this.transform.Find("BackPanel").gameObject.GetComponent<Animator>();
- }
- public override void Display(BaseUIForm _parent, Dictionary<string, string> data)
- {
- string message;
- data.TryGetValue("message", out message);
- messageText.text = message;
- isEnd = false;
- showTime = 2;
- disTime = DateTime.Now;
- base.Display(_parent, data);
- animator.Play("MsgOAnimation");
- }
- // Update is called once per frame
- void Update() {
- if (isEnd)
- {
- AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
- // 判断动画是否播放完成
- if (info.normalizedTime >= 1.0f)
- {
- //播放完毕,要执行的内容
- Hiding();
- }
- }
- TimeSpan toNow = DateTime.Now - disTime;
- int leftTime = showTime - (int)toNow.TotalSeconds;
- if (leftTime <= 0)
- {
- animator.Play("MsgCAnimation");
- isEnd = true;
- }
- }
- }
- }
|