blob: 64732f7aca86e4289890471a4a003ed3e2dd4f79 (
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
28
29
30
31
32
33
34
35
36
37
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 ();
}
}
}
}
}
|