[Unity3d tutorial] Use UILabel and UIButton to create a counter

Source: Internet
Author: User

First, double-click to import the required NGUI package.


The following is the import prompt. We need to import all of them here.


Project file after NGUI Import


After importing NGUI, The NGUI option will appear in the top menu bar. Delete the default Main Camera and create a New UI.


When you create a new UI, the following


The next step is to create the NGUI component and create a widget.


The widget tool window appears after you click it.

When you click the template in the window, the following list is displayed, showing NGUI components. Here we will use the label and button components.


All the image materials in NGUI need to be read from atlas. Here we use NGUI materials.

Drag two items to the widget tool, select button, add to panel, and each component requires a parent node. Here we select panel as the parent node.



Here we select label as the template and add to panel.


In this way, we have added two components: button and text. Next, we will add a script to connect the two components.


Create the script btn_click_1 with the following content:

Drag the script to the button script, select the script, and pull the label component to the LB variable in the script.


Completed:


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.