Unity Ngui Implement Mobile Input method recognition Event response

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.