Created
August 30, 2018 07:51
-
-
Save Demkeys/fafeaedd758c47e94ba795251d8fb879 to your computer and use it in GitHub Desktop.
KeyEventComparer for GOTO Logic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
namespace GOTO.Logic.Comparers | |
{ | |
[Serializable] | |
[ComparerCategory("Comparer")] | |
public class KeyEventComparer : Comparer | |
{ | |
public enum KeyEventType { KeyDown, KeyUp, KeyPress }; | |
public KeyEventType keyEventType; | |
public KeyCode key; | |
public override bool Compare() | |
{ | |
bool result = false; | |
if(keyEventType == KeyEventType.KeyDown) | |
result = Input.GetKeyDown(key); | |
else if(keyEventType == KeyEventType.KeyUp) | |
result = Input.GetKeyUp(key); | |
else if(keyEventType == KeyEventType.KeyPress) | |
result = Input.GetKey(key); | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment