NGUI 3.5 Tutorial (vii) Input box

Source: Internet
Author: User

Tribute to the original http://blog.csdn.net/chenggong2dm/article/details/38332089

write in front:


This article will use Ngui to create a glorified input box.
Welcome everyone to correct, shoot bricks! Original very hard, if reproduced, please indicate the source.

Create an input box

In Ngui 3.5, the creation of a control can be accomplished by "searching" and then "dragging" (also Ngui recommended method).

(1) In the project panel, search for "control", that is, search controls. After that, you'll find a bunch of Ngui controls.

(2) Locate the simple Input Field and drag to the bottom of the hierarchy panel. I'm dragging it right down to the UI root.

In the game view, this control appears as follows:

(3) Beautify the input box. Our art certainly will not be satisfied with this type of input box, then we have to replace its style, is actually to give the control a basemap.

Select the input box and change the Atlas and Sprite in the Inspector panel to modify the Basemap. If you do not understand how to build Atlas and Sprite, please refer to my previous article "NGUI 3.5 tutorial (iv) Atlas and Sprite (make Picture button)".

(4) Change the font of the input box. Since we want to apply a custom font, we have to put the good font, set on. If you do not understand the font production, please refer to my previous article "NGUI 3.5 tutorial (six) font fonts."

(5) Change the position of the text in the input box. Define the font, font size, you will find that the word in the input box is not centered, some biased. You need to adjust the anchors under the label:

Method Two: You can set the type of anchors to none, and then adjust by transform.

(6) Run, try the input effect:

What to note about the input box is:

1, if there is no custom font, the input of Chinese is transparent (blank), can not be displayed.

2, if the font exceeds the size of the input box, the same cannot be displayed.

3, using dynamic fonts will increase the draw call.

4, in the phone, click on the input box, will automatically call the phone's virtual keyboard, and then enter.

NGUI 3.5 Tutorial (vii) Input box

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.