Primary applications of Unity3d-ugui

Source: Internet
Author: User

To Add a font:

Drag the downloaded font to the Project panel-click the dot after the Text property in the text component-Select the font you just dragged.

Create togglegroup (switch group):

1. Create two toggle under a canvas

2. Create an empty object under the canvas (named Togglegroup) and add a Togglegroup component to the Togglegroup

3. Select the two toggle, drag the Togglegroup to the toggle component's group position, that is, complete the selection between two options (the Togglegroup component of allow Switch off can be allowed to do not select, But does not support multiple selection)

There are two ways to add controls to listen on events (for example, button):

Method One: This method has less code to write, but has more operations in unity

1. Create an empty object (named Uguictrl) in the Hieraychy panel and Add the button control.

2. Create a C # script named Uguiscr and hang the script on the Uguictrl.

2. Open script Write a public method-print 123

 Public void Print123 () {Print ("123");  }

After running, when you click the button, the console panel will print 123.

Method Two: This method code writes more, but the operation in unity is relatively small.

1. Create an empty object (named Uguictrl) in the Hieraychy panel and Add the button control.

2. Create a C # script named Uguiscr and hang the script on the Uguictrl.

2. Open the script to write a public method-print 123.

 Public classuguictrl:monobehaviour{//Get button Component     PublicButton Buttonctrl; voidStart () {//method written in Strat.ButtonCtrl.onClick.AddListener (Print123); }    //This method can be written in the form of a lambda expression     Public voidPrint123 () {print ("123"); }}

After running, when you click the button, the console panel will print 123.

Primary applications of Unity3d-ugui

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.