Ngui has implemented the event monitoring function, see: On Return Key (select Snbmit), you can register the monitoring event directly.
The implementation is as follows:
1. Build a simple scene
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/9B/79/wKioL1ljf-PRBtGxAAKAx5hV9OQ336.png-wh_500x0-wm_ 3-wmp_4-s_1229982714.png "title=" 1.png "alt=" Wkiol1ljf-prbtgxaakax5hv9oq336.png-wh_50 "/>
2. Create a new script InputTest.cs mount under Input object and drag and drop the value txt_content, input
Using unityengine;//author through integrated Inputfield, monitor the state of the software disk in Update capture to carriage return event public class inputtest:monobehaviour{public UILabel txt _content; public uiinput input; void Onenable () {Eventdelegate.add (input.onsubmit, returncallback); } void Ondisable () {eventdelegate.remove (input.onsubmit, returncallback); } public void Returncallback () {txt_content.text = Input.value; }}
3, run the game, enter the content in input after the return, content will be assigned the value just entered (carriage return function equivalent to the mobile side of the confirmation button, packed apk test)
The effect is as follows:
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/9B/7A/wKiom1ljgebRvg1JAAQf7cA8oVc097.png-wh_500x0-wm_ 3-wmp_4-s_3066755004.png "title=" 2.png "alt=" Wkiom1ljgebrvg1jaaqf7ca8ovc097.png-wh_50 "/>
Unity Ngui Implement Mobile Input method recognition Event response