GetMouseButton.cs 730 B

123456789101112131415161718192021222324252627
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityInput
  3. {
  4. [TaskCategory("Unity/Input")]
  5. [TaskDescription("Stores the state of the specified mouse button.")]
  6. public class GetMouseButton : Action
  7. {
  8. [Tooltip("The index of the button")]
  9. public SharedInt buttonIndex;
  10. [RequiredField]
  11. [Tooltip("The stored result")]
  12. public SharedBool storeResult;
  13. public override TaskStatus OnUpdate()
  14. {
  15. storeResult.Value = Input.GetMouseButton(buttonIndex.Value);
  16. return TaskStatus.Success;
  17. }
  18. public override void OnReset()
  19. {
  20. buttonIndex = 0;
  21. storeResult = false;
  22. }
  23. }
  24. }