summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Input/GetKey.cs
blob: 5fd8807a8c8e8b73f93be39be5974e9ccd8424a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using UnityEngine;

namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityInput
{
    [TaskCategory("Basic/Input")]
    [TaskDescription("Stores the pressed state of the specified key.")]
    public class GetKey : Action
    {
        [Tooltip("The key to test.")]
        public KeyCode key;
        [RequiredField]
        [Tooltip("The stored result")]
        public SharedBool storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = Input.GetKey(key);
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            key = KeyCode.None;
            storeResult = false;
        }
    }
}