MouseSelector.cs 538 B

1234567891011121314151617181920212223
  1. using System;
  2. using UnityEngine;
  3. namespace Rokid.UXR.Interaction {
  4. public class MouseSelector : MonoBehaviour, ISelector
  5. {
  6. public event Action WhenSelected;
  7. public event Action WhenUnselected;
  8. void Update()
  9. {
  10. if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.JoystickButton0))
  11. {
  12. WhenSelected?.Invoke();
  13. }
  14. if (Input.GetMouseButtonUp(0) || Input.GetKeyUp(KeyCode.JoystickButton0))
  15. {
  16. WhenUnselected?.Invoke();
  17. }
  18. }
  19. }
  20. }