123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using UnityEngine;
- namespace Rokid.UXR.Interaction {
- public class ButtonMouseSelector : MonoBehaviour, ISelector
- {
- public event Action WhenSelected;
- public event Action WhenUnselected;
-
- private bool isCanClick = true;
- public void setClickEnable(bool enable)
- {
- isCanClick = enable;
- }
-
- void Update()
- {
- if (!isCanClick)
- {
- return;
- }
-
- #if UNITY_EDITOR
- if (Input.GetKeyDown(KeyCode.KeypadEnter))
- {
- WhenSelected?.Invoke();
- }
- if (Input.GetKeyUp(KeyCode.KeypadEnter))
- {
- WhenUnselected?.Invoke();
- }
- #else
- if (Input.GetKeyDown(KeyCode.JoystickButton0))
- {
- WhenSelected?.Invoke();
- }
-
- if (Input.GetKeyUp(KeyCode.JoystickButton0))
- {
- WhenUnselected?.Invoke();
- }
- #endif
- }
- }
- }
|