using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class EmulatorGUI : MonoBehaviour { private Dictionary keyboardKeyCodeMap; private Emulator emulator; void Start() { keyboardKeyCodeMap = new Dictionary() { { GBAKeyCode.Start,KeyCode.Return}, { GBAKeyCode.Select,KeyCode.Backspace}, { GBAKeyCode.Left,KeyCode.A}, { GBAKeyCode.Right,KeyCode.D}, { GBAKeyCode.Up,KeyCode.W}, { GBAKeyCode.Down,KeyCode.S}, { GBAKeyCode.A,KeyCode.J}, { GBAKeyCode.B,KeyCode.K}, { GBAKeyCode.L,KeyCode.U}, { GBAKeyCode.R,KeyCode.I}, }; emulator = GameObject.FindObjectOfType(); emulator.KeyPressed += GetKey; } public bool GetKey(GBAKeyCode keyCode) { #if UNITY_EDITOR || UNITY_STANDALONE bool input = Input.GetKey( keyboardKeyCodeMap[keyCode]); if(input) return true;else return false; #endif } }