Unity dynamically adds and deletes iGUI controls

Source: Internet
Author: User


In iGUI, you cannot see the control if Enable is set to false, but it is not removed. Today I will talk about how to add and delete the iGUI control in unity dynamically.

1. Add: iGUI. iGUIRoot. addElement ("iGUIProgressBar ");

2. Remove: iGUI. iGUIRoot. removeElement (iGUI. iGUIElement );

Let's take a look at my example:
 
[Java]
<Pre class = "html" name = "code"> var root: iGUI. iGUIRoot;
Var chun: iGUI. iGUIProgressBar;
Function OnGUI (){
If (GUI. Button (Rect (100,100,), "add ")){
Chun = root. addElement ("iGUIProgressBar"); // iGUIxxx must be written;
Chun. name = "chun ";
}
If (GUI. Button (Rect (0,110,100,100), "remove ")){
Root. removeElement (chun); // there must be no "". Otherwise, an error is returned.
}
}

Note: The chun of removeElement is var chun: iGUI. iGUIProgressBar; the chun in it is not chun. name = "chun ";
I didn't change the height of iGUIProgressBar in the past. Later I found that I should change the --> Fixed Height of Empty Style and Fill Style to 0 ~~~


From dlnuchunge's column

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.