Create a keyboard event.
function OnGUI () { GUILayout.Label ("Press Enter To Start Game"); if (Event.current.Equals (Event.KeyboardEvent ("[enter]"))) Application.LoadLevel (1); if (Event.current.Equals (Event.KeyboardEvent ("return"))) print ("I said enter, not return - try the keypad"); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void OnGUI() { GUILayout.Label("Press Enter To Start Game"); if (Event.current.Equals(Event.KeyboardEvent("[enter]"))) Application.LoadLevel(1); if (Event.current.Equals(Event.KeyboardEvent("return"))) print("I said enter, not return - try the keypad"); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def OnGUI() as void: GUILayout.Label('Press Enter To Start Game') if Event.current.Equals(Event.KeyboardEvent('[enter]')): Application.LoadLevel(1) if Event.current.Equals(Event.KeyboardEvent('return')): print('I said enter, not return - try the keypad')