Newer
Older
John Schihada
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToolModeText : MonoBehaviour
{
private bool timerActive { get; set; }
private float timer { get; set; }
private float timerDuration = 3.0f;
// Start is called before the first frame update
void Start()
{
gameObject.GetComponentInChildren<UnityEngine.UI.Text>().CrossFadeAlpha(0.0f, 0.0f, false);
gameObject.GetComponentInChildren<UnityEngine.UI.Text>().CrossFadeAlpha(1.0f, 0.9f, false);
this.timerActive = true;
this.timer = 0;
CommunicationEvents.ToolModeChangedEvent.AddListener(OnToolModeChanged);
}
// Update is called once per frame
void Update()
{
//If the Timer is Active, check if timerDuration is reached and set the Text inactive
if (this.timerActive)
{
this.timer += Time.deltaTime;
if (this.timer >= this.timerDuration)
{
//gameObject.SetActive(false);
gameObject.GetComponentInChildren<UnityEngine.UI.Text>().CrossFadeAlpha(0.0f, 0.3f, false);
this.timerActive = false;
this.timer = 0;
}
}
}
void OnToolModeChanged(ToolMode ActiveToolMode) {
//When ToolMode changes: Start a new Timer for showing up the Text for it
gameObject.GetComponentInChildren<UnityEngine.UI.Text>().text = "ToolMode = " + ActiveToolMode;
//gameObject.SetActive(true);
gameObject.GetComponentInChildren<UnityEngine.UI.Text>().CrossFadeAlpha(1.0f, 0.3f, false);
this.timerActive = true;
this.timer = 0;
}
}