Any way to receive "key pressed" event? In older posts they are present. Main idea of console. Need help in pseudocode section. Code (CSharp): using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System.Collections; public class Console : MonoBehaviour, ISubmitHandler { public Text text; public string input; private ConsoleLog log; //container for console log private ConsoleCmdPool commands; public void Awake() { log = ConsoleLog.Instance; commands = ConsoleCmdPool.Instance; text = GetComponent<Text>(); } // refresh text in uGUI element public void InputUpdated() { text.text = log.Log() + "\n" + input; } // PSEUDOCODE HERE public void SomeEvent(EventData data) { input += data.PressedKey; InputUpdated(); } // END OF PSEUDOCODE // on Enter pressed public void OnSubmit(BaseEventData data) { log.Log(input); input = ""; InputUpdated(); } }
Okay. New question. Why this code sends 2 events. First - clear(or some escape character, dunno), second - letter. Code (CSharp): public void OnUpdateSelected(BaseEventData data) { while(Event.PopEvent(mEvent)) { if(mEvent.rawType == EventType.KeyDown) { Debug.Log(mEvent.character); input+=mEvent.character; InputUpdated(); } } } Solved it anyway. Code (CSharp): char c = mEvent.character; if(c != 0) input+=c.ToString(); InputUpdated();