spinningcube/Assets/Scripts/PopupNotification.cs
Shaun M Reed 33664d2735 Added basic notification system
-Works with minimal calls to SendNotification(), infinite loop possible
on multiple calls
-Add to MoreExp()
--Add case for multiple notifications of same type combining value
--If notification timer > maxTime
---expRate = expNotifyValue / secondsPassed
---Display Exp/s instead of continuously growing value
2017-09-04 19:53:18 -04:00

39 lines
895 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PopupNotification : MonoBehaviour {
public bool active = false;
public Vector3 origin;
public float timer = 0.0f;
public string localNotify;
// Use this for initialization
void OnEnable () {
active = true;
origin = this.transform.localPosition;
localNotify = GameObject.Find("EventSystem").GetComponent<GameManager>().GetNotify();
}
// Update is called once per frame
void FixedUpdate () {
timer += 0.02f;
this.gameObject.transform.Translate(new Vector3(0, 10f * Time.deltaTime, 0));
this.gameObject.GetComponentInChildren<Text>().text = localNotify;
if(timer >= 3)
{
this.gameObject.SetActive(false);
active = false;
timer = 0.0f;
this.gameObject.transform.localPosition = origin;
}
}
}