forked from mattsemar/dsp-bulldozer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckboxControl.cs
More file actions
56 lines (51 loc) · 1.4 KB
/
CheckboxControl.cs
File metadata and controls
56 lines (51 loc) · 1.4 KB
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
48
49
50
51
52
53
54
55
56
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Bulldozer
{
public class CheckboxControl : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
private GameObject _hoverText;
public string HoverText = "";
public event Action<PointerEventData> onClick;
public Text textObject;
public void Start()
{
if (textObject != null)
{
_hoverText = textObject.gameObject;
_hoverText.SetActive(false);
textObject.text = HoverText;
}
}
public void OnPointerEnter(PointerEventData eventData)
{
if (_hoverText == null)
{
Console.WriteLine("hovertext not initialized");
Start();
}
else
{
_hoverText.SetActive(true);
}
}
public void OnPointerExit(PointerEventData eventData)
{
if (_hoverText == null)
{
Console.WriteLine("hovertext not initialized");
Start();
}
else
{
_hoverText.SetActive(false);
}
}
public void OnPointerClick(PointerEventData eventData)
{
onClick?.Invoke(eventData);
}
}
}