Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System;
- using System.Collections.Generic;
- public class DumbInput : MonoBehaviour {
- public KeyCode[] keysToListenFor;
- List<KeyCode> keyCodesThisFrame = new List<KeyCode>();
- void Update () {
- keyCodesThisFrame.Clear();
- if( keysToListenFor.Length == 0 ) {
- keysToListenFor = Enum.GetValues(typeof(KeyCode)) as KeyCode[];
- }
- foreach( KeyCode key in keysToListenFor ) {
- if( Input.GetKeyDown(key) ) {
- keyCodesThisFrame.Add(key);
- }
- }
- foreach( var key in keyCodesThisFrame ) {
- switch( key ) {
- case KeyCode.A:
- Debug.Log("A was hit!");
- break;
- case KeyCode.B:
- Debug.Log("B was hit!!");
- break;
- case KeyCode.C:
- Debug.Log("C was hit!!!");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement