43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class KillFeedEntry : MonoBehaviour
|
|
{
|
|
private float AliveTime;
|
|
private float _t;
|
|
public Text txt;
|
|
void Awake(){
|
|
if(txt==null){txt = GetComponent<Text>();}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(_t < AliveTime){
|
|
_t+=Time.deltaTime;
|
|
return;
|
|
}else if(_t < AliveTime * 2){
|
|
_t+=Time.deltaTime;
|
|
float p = (_t - AliveTime)/AliveTime;
|
|
txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, 1f-p);
|
|
}else{
|
|
Die();
|
|
}
|
|
}
|
|
|
|
|
|
public void SetEntry(string text, float aliveTime = 1){
|
|
AliveTime=aliveTime;
|
|
txt.text = text;
|
|
txt.color = new Color(txt.color.r, txt.color.g, txt.color.b, 1);
|
|
_t = 0;
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public void Die(){
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|