Tanoda
TrackerHandPicker.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using NaughtyAttributes;
4using UnityEngine;
6using UnityEngine.UI;
7
8public class TrackerHandPicker : MonoBehaviour
9{
10 public GameObject selector, hudCanvas;
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}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7
System.Drawing.Image Image
Definition: TestScript.cs:37