59 lines
1.2 KiB
C#
59 lines
1.2 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
public class Notification{
|
|
public GameObject source;
|
|
public string text;
|
|
}
|
|
|
|
public enum NotificationElement{
|
|
Text,
|
|
Item,
|
|
ImportantText
|
|
}
|
|
|
|
public class NotificationsController : MonoBehaviour {
|
|
public HudController hud;
|
|
private static string itemColor = "00ff00ff";
|
|
|
|
private static List<Notification> _notifications = new List<Notification>();
|
|
|
|
public static void AddNotification(Notification n){
|
|
_notifications.Add(n);
|
|
}
|
|
|
|
public static string AppendString(string src, string txt, NotificationElement elementType){
|
|
var result = src;
|
|
if(elementType == NotificationElement.Item){
|
|
result += "<color=#" + itemColor + ">" + txt + "</color>";
|
|
}else if(elementType == NotificationElement.ImportantText){
|
|
result += "<i><b>" + txt + "</b></i>";
|
|
}else{
|
|
result += txt;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static void RemoveNotification(Notification n){
|
|
_notifications.Remove(n);
|
|
}
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
}
|
|
|
|
void OnGUI(){
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
if(_notifications != null && _notifications.Count > 0){
|
|
hud.SetNotify(_notifications[0].text);
|
|
}else{
|
|
hud.SetNotify("");
|
|
}
|
|
}
|
|
}
|