1
Fork 0
slime-blood-and-pain/Assets/Scripts/MessageBar.cs

33 lines
695 B
C#
Raw Normal View History

2019-04-28 13:29:17 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MessageBar : MonoBehaviour
{
public float disappearanceSpeed = 0.3f;
private float opacity;
private Text text;
// Start is called before the first frame update
void Start()
{
text = GetComponent<Text>();
opacity = 0f;
}
public void Write(string message) {
text.text = message;
opacity = 1f;
}
void Update()
{
if(opacity > 0f) {
opacity -= disappearanceSpeed * Time.deltaTime;
}
text.color = new Color(text.color.r, text.color.g, text.color.b, opacity);
}
}