Documentation for the Unity C# Library
Loading...
Searching...
No Matches
CheatListener.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using Autohand.Demo;
4using UnityEngine;
5
6namespace PixoVR.Event
7{
8 public class CheatListener : MonoBehaviour
9 {
10 [SerializeField]
11 private GameObject debugUI;
12
13 [SerializeField] private InteractableDebug _interactableDebug;
15 [SerializeField]
16 private XRHandControllerLink leftHandControllerLink;
17
18 [SerializeField]
19 private List<CommonButton> _pressedButtons;
20
21 private int counter = 0;
22 private bool showDebugUI = false;
23 private bool _secondaryButtonPressed = false;
24 private bool _primaryButtonPressed = false;
25
26
27 void Update()
28 {
29 if (showDebugUI) return;
30
31 if (leftHandControllerLink.ButtonPressed(CommonButton.secondaryButton) && !_secondaryButtonPressed)
32 {
34 CheckCombination(CommonButton.secondaryButton);
35 }
36
37 if (!leftHandControllerLink.ButtonPressed(CommonButton.secondaryButton) && _secondaryButtonPressed)
38 {
40 }
41
43 if (leftHandControllerLink.ButtonPressed(CommonButton.primaryButton) && !_primaryButtonPressed)
44 {
46 CheckCombination(CommonButton.primaryButton);
47 }
48 if (!leftHandControllerLink.ButtonPressed(CommonButton.primaryButton) && _primaryButtonPressed)
49 {
51 }
52 }
53
54 private void CheckCombination(CommonButton button)
55 {
56 if (_pressedButtons[counter] == button)
57 {
58 ++counter;
59 if (counter == _pressedButtons.Count)
60 {
61 showDebugUI = true;
62 debugUI.SetActive(true);
63 _interactableDebug.CloseDebugUI += () =>
64 {
65 counter = 0;
66 showDebugUI = false;
67 debugUI.SetActive(false);
68 };
69 }
70 }
71 else
72 {
73 counter = 0;
74 }
75 }
76 }
77}
GameObject debugUI
[SerializeField]
List< CommonButton > _pressedButtons
[SerializeField]
InteractableDebug _interactableDebug
[SerializeField]
XRHandControllerLink leftHandControllerLink
[SerializeField]
void CheckCombination(CommonButton button)