Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 missypooh · Jul 22, 2011 at 07:04 AM · beginnerboolean

How come GUI window are not close according

 var isWrong                       = false;
 
 function Update()
 {
 
 .
 .
 .
 
 else if(selected_00.GetComponent(textOnMouse00).thisRadical.ID != selected_0.GetComponent(textOnMouse0).thisRadical.ID)
 {
 
                 isWrong = true;
                 //score   -= 500;
             }
         }
     }
 
 
 
 function OnGUI()
 {
       
     if(isWrong)
     {
         GUI.Window(0, Rect((Screen.width/2)-90, (Screen.height/2)-190, 300, 150), showGUI, "I'm Sorry!!");
     }
     
 }
 
 function showGUI()
 {
 
 if(isWrong)
 {
 
 // You may put a label to show a message to the player
 
 GUI.Label(Rect(65, 50, 200, 80), "Boo..Boo.. WRONG WORDS!!!");
 
 }
     
 // You may put a button to close the pop up too 
 
 if (GUI.Button(Rect(60, 90, 75, 30), "OK"))
 
 {
 
 isWrong = false;
 
 }
 
 }
 

I would like to ask what wrong with my code. It can't seem to close the window if i click ok.

Comment
Add comment · Show 1
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 CHPedersen · Jul 22, 2011 at 07:10 AM 0
Share

(Edited post to fix code formatting)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CHPedersen · Jul 22, 2011 at 07:13 AM

It's possible that the conditional that sets isWrong = true continually evaluates to true, i.e. selected_00.GetComponent(textOnMouse00).thisRadical.ID is never equal to selected_0.GetComponent(textOnMouse0).thisRadical.ID, so even if the Window's Ok-button sets isWrong = false, it gets set right back to true next time Update executes. If I were you, I'd insert a call to Debug.Log inside that if-statement and see if it gets printed to the console continually.

Comment
Add comment · Show 3 · 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
avatar image missypooh · Jul 22, 2011 at 12:39 PM 0
Share

Yes, i think you are right. so how do i solve this??

avatar image CHPedersen · Jul 22, 2011 at 12:43 PM 0
Share

You make sure isWrong doesn't get continually set to true. ;) That is, of course, a bleeding obvious comment and not very useful to you, but that's because I don't know what lies behind selected_00.GetComponent(textOn$$anonymous$$ouse00).thisRadical.ID, what that ID is, when it gets set, whether one of them returns null, or something like that. You need to study that and figure that out for yourself.

avatar image missypooh · Jul 22, 2011 at 01:01 PM 0
Share

hello. Noted. Thank you

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Help understanding when a boolean is set to true 1 Answer

How to activate gameObjects based on a boolean from another scene? 1 Answer

Cannot Locate Boolean in different script 4 Answers

Animations in booleans loop? 1 Answer

Boolean being chaned on new scene load 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