You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
947 B
48 lines
947 B
10 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
|
[EventHandlerInfo("Input",
|
||
|
"Key Pressed",
|
||
10 years ago
|
"The block will execute when a key press event occurs.")]
|
||
10 years ago
|
[AddComponentMenu("")]
|
||
10 years ago
|
public class KeyPressed : EventHandler
|
||
|
{
|
||
|
public enum KeyPressType
|
||
|
{
|
||
|
KeyDown, // Execute once when the key is pressed down
|
||
|
KeyUp, // Execute once when the key is released
|
||
|
KeyRepeat // Execute once per frame when key is held down
|
||
|
}
|
||
|
|
||
|
public KeyPressType keyPressType;
|
||
|
|
||
|
public KeyCode keyCode;
|
||
|
|
||
|
protected virtual void Update()
|
||
|
{
|
||
|
switch (keyPressType)
|
||
|
{
|
||
|
case KeyPressType.KeyDown:
|
||
|
if (Input.GetKeyDown(keyCode))
|
||
|
{
|
||
10 years ago
|
ExecuteBlock();
|
||
10 years ago
|
}
|
||
|
break;
|
||
|
case KeyPressType.KeyUp:
|
||
|
if (Input.GetKeyUp(keyCode))
|
||
|
{
|
||
10 years ago
|
ExecuteBlock();
|
||
10 years ago
|
}
|
||
|
break;
|
||
|
case KeyPressType.KeyRepeat:
|
||
|
if (Input.GetKey(keyCode))
|
||
|
{
|
||
10 years ago
|
ExecuteBlock();
|
||
10 years ago
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|