Controls the display of the same form (toggle and button)

Source: Internet
Author: User

Script for public variables

usingUnityengine;usingSystem.Collections;usingUnityengine.ui; Public classCommonvalues:monobehaviour { PublicGameobject Answershowwin;//Answer display window     PublicButton closebtn;  PublicGameobject Submittog;//Submit an Answer    voidStart () {}voidUpdate () {}}

Toogle and buttons control the display of the same window

usingUnityengine;usingSystem.Collections;usingUnityengine.ui; Public classtogglecontrol:monobehaviour{PrivateGameobject _submittog; //Control the explicit toggle of the window PrivateGameobject _answershowwin; //Window  PublicGameobject COMMONVALUESBG;//mount a background image of a public variable    PrivateButton _closebtn; BOOLFlag//get the status of the switch    BOOLClosebtnflag;//get the state of a window    int_clickbtnno;//determine whether the clicked parameter    voidAwake () {
//Get variable from commonvaluse script _submittog= commonvaluesbg.getcomponent<commonvalues>(). Submittog; _answershowwin= commonvaluesbg.getcomponent<commonvalues>(). Answershowwin; _CLOSEBTN= commonvaluesbg.getcomponent<commonvalues>(). CLOSEBTN;
_answershowwin.setactive (false); } voidStart () {eventtriggerlistener.get (_submittog). OnClick+=Togclick; _closebtn.onclick.addlistener (Delegate { This. Closebtnclick (); }); } voidTogclick (gameobject tog) {flag= _submittog.getcomponent<toggle>(). IsOn; _answershowwin.setactive (flag); } voidClosebtnclick () {Closebtnflag=_answershowwin.activeself; if(closebtnflag==true) {_answershowwin.setactive (false); _submittog.getcomponent<Toggle> (). IsOn =false; Flag=false; } }}

Controls the display of the same form (toggle and button)

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.