Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mike hwang · Nov 04, 2014 at 03:24 AM · buttonscript.

How to control NGUI button by script

Many page said you just modify UIToggle.vale. It'll change all button status and call Callback function automaticly. It's work fine when My Ap start running and initial function set the UIToggle.vale to default value. But It make very strange when control by another Button's Script. All flag has be setting but CallBack and Active/Deactive Object not following! Any one knew loss something?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mike hwang · Nov 04, 2014 at 07:43 AM 0
Share

Thank you for your answer. Sorry, not really clear.

Seems like code:

 //two groups button
 // 1. ABC buttons
 // 2. 123 buttons
 public void ABCBtnValueChange(){  // attach on UIToggle of ABC button "On Value Change"
 
     // when click button ABC It'll change button 123 status.( button 123 on)
     if( UIToggle.current.value) {
         Btn123UIToggle.value = true;
         Btn123UIToggle.value = false;
     }
 }

Nothing change on Button 123! When I trace over "Btn123UIToggle.value = false" the UIToggle.value is not change to false!. nothing change in Button 123.( no Highligh, no calling "On Value chage" callback of Button 123

avatar image mike hwang · Nov 05, 2014 at 06:22 AM 0
Share

Yes! I have founded problem. We can't setting UIToggle value of Button-123 when button-ABC be press at same time(frame). Just move to next frame that button-ABC all event has been process. The code must be change to :

 void Update()
 {
     if(button-123 light-on Require)
     {
         setting UIToggle value of Button-123 to "true".
         Off button-123 light-on Require flag.
     }
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by b1gry4n · Nov 04, 2014 at 05:11 AM

     UIToggle.current.value = true;
     UIToggle.current.value = false;

You can create a reference to the UIToggle and update that specific toggle script.

     public UIToggle myToggle;
     
     myToggle.current.value = true;
     myToggle.current.value = false;

In the UIToggle script you need to link it to a function on value change. This is located under the "On value change", "Notify"

create a script containing:

     public void ToggledValue(){ //name whatever you want
 
         if(UIToggle.current.value){
             //the value is true, do something
         }else if (!UIToggle.current.value){
             //the value is false, do something
         }
     }

Drag the script containing the "ToggledValue" function into the UIToggle component under notify and select the function "ToggledValue" so that when the UIToggle changes, it will call that function

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I need to move a sprite when an UI button is clicked 1 Answer

How to use a button to trigger an Animator Parameter 0 Answers

Unity multiple button on click 1 Answer

void dont show up in on click 1 Answer

a live updating button panel? pulling from an external api? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges