60 lines
1.1 KiB
C#
60 lines
1.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace DebuggingEssentials
|
|
{
|
|
[Serializable]
|
|
public class AdvancedKey
|
|
{
|
|
public KeyCode keyCode;
|
|
|
|
public int specialKeys;
|
|
|
|
public AdvancedKey(KeyCode keyCode, bool shift = false, bool control = false, bool alt = false)
|
|
{
|
|
this.keyCode = keyCode;
|
|
specialKeys = (shift ? 1 : 0) | (control ? 2 : 0) | (alt ? 4 : 0);
|
|
}
|
|
|
|
public bool GetSpecialKeys()
|
|
{
|
|
if ((specialKeys & 1) != 0 && !EventInput.isShiftKey)
|
|
{
|
|
return false;
|
|
}
|
|
if ((specialKeys & 2) != 0 && !EventInput.isControlKey)
|
|
{
|
|
return false;
|
|
}
|
|
if ((specialKeys & 4) != 0 && !EventInput.isAltKey)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool GetKeyUp(Event currentEvent)
|
|
{
|
|
if (currentEvent.type == EventType.KeyUp && currentEvent.keyCode == keyCode)
|
|
{
|
|
return GetSpecialKeys();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool GetKey(Event currentEvent)
|
|
{
|
|
if (currentEvent.keyCode == keyCode)
|
|
{
|
|
return GetSpecialKeys();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool OnlyGetKey(Event currentEvent)
|
|
{
|
|
return currentEvent.keyCode == keyCode;
|
|
}
|
|
}
|
|
}
|