/****************************************************
文件:WndDynamic.cs
作者:李疆
邮箱: 2906718132@qq.com
日期:2019/3/13 21:24:10
功能:Nothing
*****************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WndDynamic : WindowRoot
{
public Text txtTips;
public Animation aniTip;
private bool isTipsShow = false;
private Queue<string> tipsQuene = new Queue<string>();
private void Start()
{
SetText(txtTips, "");
}
private void Update()
{
if(tipsQuene .Count >0&&isTipsShow ==false )
{
lock (tipsQuene)
{
string tips = tipsQuene.Dequeue();
isTipsShow = true;
SetTips(tips);
}
}
}
public void AddTips(string tips)
{
lock(tipsQuene)
{
tipsQuene.Enqueue(tips);
}
}
private void SetTips(string tips)
{
SetActive(txtTips, true);
SetText(txtTips, tips);
AnimationClip clip = aniTip.GetClip("AniTips");
aniTip.Play();
//延时关闭激活状态
StartCoroutine(AniPlayDone(clip.length, () =>
{
SetActive(txtTips, false);
isTipsShow = false;
}));
}
private IEnumerator AniPlayDone(float time ,Action loaded)
{
yield return new WaitForSeconds(time);
if(loaded !=null)
{
loaded();
}
}
}
还没有评论,来说两句吧...