62 lines
1.2 KiB
C#
62 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public enum DisplayMessageType
|
|
{
|
|
DeviceLost,
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class DisplayMessage
|
|
{
|
|
public DisplayMessageType Type;
|
|
[TextArea]
|
|
public string Message;
|
|
public int Time;
|
|
}
|
|
|
|
public class UIInfoDisplay : MonoBehaviour
|
|
{
|
|
public static UIInfoDisplay Instance;
|
|
|
|
[SerializeField]
|
|
private UITextShow _infoText;
|
|
[SerializeField]
|
|
private List<DisplayMessage> messages = new List<DisplayMessage>();
|
|
|
|
public UIDisplayMessage DisplayMessagePrefab;
|
|
|
|
private Dictionary<DisplayMessageType, UIDisplayMessage> showedMessages = new Dictionary<DisplayMessageType, UIDisplayMessage>();
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public void ShowInfo(DisplayMessageType type)
|
|
{
|
|
var selected = messages.Find(x => x.Type == type);
|
|
|
|
if (!showedMessages.ContainsKey(type))
|
|
{
|
|
|
|
}
|
|
|
|
_infoText.SetText(selected.Message);
|
|
}
|
|
|
|
public void HideInfo(DisplayMessageType type)
|
|
{
|
|
|
|
}
|
|
}
|