Tanoda
TrackerHandPicker.cs
Go to the documentation of this file.
1
using
System.Collections;
2
using
System.Collections.Generic;
3
using
NaughtyAttributes;
4
using
UnityEngine
;
5
using
UnityEngine
.
Events
;
6
using
UnityEngine
.
UI
;
7
8
public
class
TrackerHandPicker
: MonoBehaviour
9
{
10
public
GameObject
selector
,
hudCanvas
;
11
public
Image
HandLoader
;
12
public
UnityEvent
onSelected
;
13
private
bool
selecting =
false
;
14
15
void
Start()
16
{
17
hudCanvas
.SetActive(
false
);
18
}
19
20
void
Update()
21
{
22
if
(!selecting)
23
{
24
var c =
HandLoader
.color;
25
c.a -= 0.01f;
26
c.a = Mathf.Max(0, c.a);
27
HandLoader
.color = c;
28
}
29
else
30
{
31
var c =
HandLoader
.color;
32
c.a += 0.01f;
33
c.a = Mathf.Min(1, c.a);
34
HandLoader
.color = c;
35
if
(c.a >= 1.0f)
36
{
37
onSelected
?.Invoke();
38
hudCanvas
.SetActive(
true
);
39
}
40
}
41
}
42
43
[
Button
]
44
private
void
Select()
45
{
46
onSelected
?.Invoke();
47
hudCanvas
.SetActive(
true
);
48
}
49
50
private
void
OnTriggerExit(Collider other)
51
{
52
if
(other.gameObject ==
selector
)
53
{
54
selecting =
false
;
55
}
56
}
57
58
private
void
OnTriggerEnter(Collider other)
59
{
60
if
(other.gameObject ==
selector
)
61
{
62
selecting =
true
;
63
}
64
}
65
}
Button
UnityEngine.UI.Button Button
Definition:
Pointer.cs:7
Image
System.Drawing.Image Image
Definition:
TestScript.cs:37
TrackerHandPicker
Definition:
TrackerHandPicker.cs:9
TrackerHandPicker.onSelected
UnityEvent onSelected
Definition:
TrackerHandPicker.cs:12
TrackerHandPicker.HandLoader
Image HandLoader
Definition:
TrackerHandPicker.cs:11
TrackerHandPicker.selector
GameObject selector
Definition:
TrackerHandPicker.cs:10
TrackerHandPicker.hudCanvas
GameObject hudCanvas
Definition:
TrackerHandPicker.cs:10
UnityEngine.Events
UnityEngine.UI
Definition:
HSVPicker/UtilityScripts/BoxSlider.cs:7
UnityEngine
Definition:
HSVPicker/UtilityScripts/BoxSlider.cs:7
Source
Assets
Scripts
TestScripts
TrackerHandPicker.cs
Generated by
1.9.3