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.
36 lines
902 B
36 lines
902 B
using UnityEngine; |
|
using UnityEngine.UI; |
|
public enum KeyMode { KeyCode, MouseButton } |
|
public class ShortcutKeys : MonoBehaviour |
|
{ |
|
public KeyMode keyMode; |
|
|
|
public KeyCode keyCode = KeyCode.Delete; |
|
public int MouseButton = 1; |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
if (GetComponent<Toggle>().isOn) |
|
{ |
|
switch (keyMode) |
|
{ |
|
case KeyMode.KeyCode: |
|
if (Input.GetKeyDown(keyCode)) |
|
{ |
|
GetComponent<Toggle>().isOn = false; |
|
} |
|
break; |
|
case KeyMode.MouseButton: |
|
if (Input.GetMouseButtonDown(MouseButton)) |
|
{ |
|
GetComponent<Toggle>().isOn = false; |
|
} |
|
break; |
|
} |
|
|
|
} |
|
|
|
|
|
} |
|
}
|
|
|