骑行页面消息通知
在线用户和影子选手用图片显示,缩放等功能按钮微调
This commit is contained in:
1 parent
2b4b2c4f70
commit
8f0598580d
37 files changed
+5951
-3153
No files matched your search
@@ -0,0 +1,76 @@
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class MessagePanelScript : MonoBehaviour
|
||||
{
|
||||
CanvasGroup canvas;
|
||||
Text text;
|
||||
RawImage head;
|
||||
string Name ="";
|
||||
string url ="";
|
||||
bool run = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
canvas = transform.GetComponent<CanvasGroup>();
|
||||
EventQueueSystem.AddListener<JoinMessageEvent>(JoinHandler);
|
||||
text = transform.Find("Name").GetComponent<Text>();
|
||||
head = transform.Find("RawImage").GetComponent<RawImage>();
|
||||
}
|
||||
private void JoinHandler(JoinMessageEvent e)
|
||||
{
|
||||
Name = e.name;
|
||||
url = e.url;
|
||||
}
|
||||
float timer = 1f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)//定时器 一秒执行一次
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
text.text = Name;
|
||||
canvas.alpha = 1;
|
||||
Name = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas.DOFade(0, 1);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
Utils.DisplayImage(head, url, false);
|
||||
url = string.Empty;
|
||||
}
|
||||
//dic.
|
||||
//foreach (var item in dic)
|
||||
//{
|
||||
// text.text = item.Key;
|
||||
// Utils.DisplayImage(head, item.Value, true);
|
||||
// dic.Remove(item.Key);
|
||||
// break;
|
||||
//}
|
||||
timer = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JoinMessageEvent : GameEvent
|
||||
{
|
||||
public string name;//人物名称
|
||||
public string url;//头像地址
|
||||
|
||||
public JoinMessageEvent(string name,string url)
|
||||
{
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user