GetKey.cs 685 B

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