summaryrefslogtreecommitdiff
path: root/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs')
-rw-r--r--Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs b/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs
new file mode 100644
index 0000000..64732f7
--- /dev/null
+++ b/Runtime/Graphs/UnityEngine.Graphs/LogicNodeLibrary/Input/OnKey.cs
@@ -0,0 +1,38 @@
+using UnityEngine;
+
+namespace UnityEngine.Graphs.LogicGraph
+{
+ public partial class InputNodes
+ {
+ [Logic]
+ [Title("Input/On Key")]
+ public sealed class OnKey : OnStateInputNode
+ {
+ private KeyCode m_Key;
+ public KeyCode key { set { m_Key = value; } }
+
+ public OnKey (GraphBehaviour graphBehaviour) : base (graphBehaviour) { }
+ public OnKey (IMonoBehaviourEventCaller graphBehaviour, KeyCode key) : base (graphBehaviour)
+ {
+ m_Key = key;
+ }
+
+ protected override void OnUpdate ()
+ {
+ if (onDown != null && Input.GetKeyDown (m_Key))
+ onDown ();
+
+ if (onUp != null && Input.GetKeyUp (m_Key))
+ onUp ();
+
+ if (down != null || up != null)
+ {
+ var stateDelegate = Input.GetKey (m_Key) ? down : up;
+ if (stateDelegate != null)
+ stateDelegate ();
+ }
+ }
+ }
+ }
+}
+