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 Bibi-Maghoo · Apr 22, 2014 at 01:29 PM · guitoggle

Close a GUI.Toggle when another opens in a different script?

Hello all. I have multiple GUI.Toggles on different scripts that when opened, change the camera view to the relevant camera in each script. This works great, but despite my best efforts they are all able to be opened, and when a second is open after the first, it disables the buttons within the Rect opened in the toggle. Here is one example, but there are about ten of these scripts on different objects in the scene. Can anyone point me in the right direction to close them? I use a doWindow function to change them, but need other scripts to tell each of the other doWindows to close when another is opened. Of course just camera.enabled= false kills the camera but does not switch back.

here is one:

     #pragma strict
      
     var oldValue : boolean = true;
     var doWindow0 : boolean = true;
     var sound : AudioClip;
     var camera1 : Camera;
     var camera2 : Camera;
      
     function Start(){
     camera1.enabled = true;
     camera2.enabled = false;
     }
      
     function DoWindow0 (windowID : int) {
     if (GUI.Button (Rect (10,20,100,80), "Offline")) {
     audio.PlayOneShot(sound);
     }
     if (GUI.Button (Rect (10,110,100,80), "Repair")) {
     audio.PlayOneShot(sound);
     
     }
     }
      
     function OnGUI () {
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.yellow;
     
     if (LaunchSatellite.satLive == true) {
     
     oldValue = doWindow0;
     doWindow0 = GUI.Toggle (Rect (1800,20,120,50), doWindow0, "Satellite View");
      
     if (oldValue != doWindow0) {
     camera1.enabled = !doWindow0;
     camera2.enabled = doWindow0;
     
     }
      
     if (doWindow0) {
     GUI.Window (0, Rect (1800,50,120,200), DoWindow0, "");
 
     }
     if (LaunchSatellite.satLive == false) {
     camera1.enabled = true;
     camera2.enabled = false;
     }
     }
     }



and another

     #pragma strict
      
     var oldValue : boolean = true;
     var doWindow0 : boolean = true;
     var sound : AudioClip;
     var camera1 : Camera;
     var camera2 : Camera;
     
     
    public static var moneyLow =  false;
    public static var moneyNorm = false;
    public static var moneyHigh = false;
    
 
    
    
      
     function Start(){
     camera1.enabled = true;
     camera2.enabled = false;
     }
      
     function DoWindow0 (windowID : int) {
     GUI.Label (Rect (10,20,180,80), "Set Shipment Quantity") ;
     GUI.Label (Rect (120,50,270,80), "Send the smallest shipment for the least return. 6 Ore / 3000 Credits per shipment") ;
     
     if (GUI.Button (Rect (10,50,100,40), "Least")) 
     moneyLow = true;
     moneyNorm = false;
     moneyHigh = false;
     
     if (moneyLow == true) 
     GUI.Label (Rect (400,60,70,80), "Selected") ;
     
     
         GUI.Label (Rect (120,120,270,80), "Send the normal shipment for the average return. 4 Ore / 6000 Credits per shipment") ;
     
     if (GUI.Button (Rect (10,120,100,40), "Normal")) 
     moneyLow = false;
     moneyNorm = true;
     moneyHigh = false;
     
     if (moneyNorm == true) {
     GUI.Label (Rect (400,130,70,80), "Selected") ;
     }
     
     }
    
      
     function OnGUI () {
     GUI.backgroundColor = Color.red;
     GUI.contentColor = Color.yellow;
     oldValue = doWindow0;
     doWindow0 = GUI.Toggle (Rect (20,260,120,50), doWindow0, "Mining");
      
     if (oldValue != doWindow0) {
     camera1.enabled = !doWindow0;
     camera2.enabled = doWindow0;
     }
      
     if (doWindow0) {
     GUI.Window (0, Rect (140,260,500,400), DoWindow0, "Ore Processing Menu");
     }
     }


Any help you can provide would be most appreciated. Thanks for reading.

Comment
Add comment · Show 3
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 Bibi-Maghoo · Apr 22, 2014 at 06:20 PM 0
Share

can anyone help? my one and only bump.

avatar image RedOrion · Feb 15, 2015 at 09:38 PM 0
Share

Did you figure it out?

avatar image Bibi-Maghoo · Feb 15, 2015 at 10:39 PM 0
Share

In the end I had to put every window into a single script, and have a bool for each set to false until it was opened. When one was opened and thus true, I then made all the others false. It works but it's messy and long.

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Whats wrong with my GUI.Toggle? 2 Answers

Is there a multiple selection ugui toggle group? 1 Answer

3 sets of button activations GUI 1 Answer

GUI toggle on click, unless on GUI. 1 Answer

why doesnt my script turn off on toggle? 1 Answer


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