123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using UnityEngine;
- using UnityEngine.Events;
- namespace Oculus.Voice.Demo
- {
- public class ButtonEventWatcher : MonoBehaviour
- {
- #if ENABLE_LEGACY_INPUT_MANAGER
-
- [SerializeField] private KeyCode[] _keys = new KeyCode[] { KeyCode.Space, KeyCode.JoystickButton0, KeyCode.JoystickButton2 };
- #endif
-
- public UnityEvent OnButtonDown;
-
- public UnityEvent OnButtonUp;
- #if ENABLE_LEGACY_INPUT_MANAGER
-
- void Update()
- {
-
- foreach (var key in _keys)
- {
- if (Input.GetKeyDown(key))
- {
- OnButtonDown?.Invoke();
- }
- else if (Input.GetKeyUp(key))
- {
- OnButtonUp?.Invoke();
- }
- }
- }
- #endif
- }
- }
|