You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
|
||
|
public class OperatingHints : MonoBehaviour {
|
||
|
/// <summary>
|
||
|
/// 提示框
|
||
|
/// </summary>
|
||
|
float alp;
|
||
|
private CanvasGroup canvas;
|
||
|
private float alpa = 0.1f;
|
||
|
private bool why = false;
|
||
|
void Start()
|
||
|
{
|
||
|
MessageDispatcher.AddListener("Operatinghints", Operating);
|
||
|
this.gameObject.SetActive(false);
|
||
|
}
|
||
|
void Update()
|
||
|
{
|
||
|
if (why == true)
|
||
|
{
|
||
|
alp = canvas.alpha;
|
||
|
alp -= Time.deltaTime * alpa;
|
||
|
canvas.alpha = alp;
|
||
|
if (canvas.alpha <= 0)
|
||
|
{
|
||
|
this.gameObject.SetActive(false);
|
||
|
why = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void Operating( IMessage message)
|
||
|
{
|
||
|
this.gameObject.SetActive(true);
|
||
|
if (message.Sender != null)
|
||
|
{
|
||
|
alpa = (float)message.Sender;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
alpa = 0.5f;
|
||
|
}
|
||
|
this.transform.SetAsLastSibling();
|
||
|
SetOperatingHints(message.Data.ToString());
|
||
|
}
|
||
|
public void SetOperatingHints(string str)
|
||
|
{
|
||
|
canvas = this.gameObject.GetComponent<CanvasGroup>();
|
||
|
this.gameObject.transform.Find("Text").GetComponent<Text>().text = str;
|
||
|
canvas.alpha = 1;
|
||
|
why = true;
|
||
|
}
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("Operatinghints", Operating);
|
||
|
}
|
||
|
}
|