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 koo_04 · Mar 26, 2012 at 03:47 PM · guibuttonwindow

Buttons in window problem

I have this window with a set of buttons in it. These buttons get made by a loop pulling information from somewhere else. It works all fine until I go to try and click a button. When I hover of the button, it looks like it gets pushed, but it is not being pushed. Then pushing the button doesn't work as well. Any ideas why?

     function gameWindow(id : int){
     var a : int = gameList.gameCount;
     var yLoc : int = -35; 
     
     for(var x = 0; x < a; x++){
         yLoc += 45;
         var gameID : int = game.id[x];
         var turnNumber : int = game.turn[x];
         var button = GUI.Button(Rect(10, yLoc, 780, 35), "Game ID: " + gameID + "   " + "Turns Completed: " + turnNumber);
         if(button){
             Debug.Log("It worked! " + gameID);
         }
     
     }
      GUI.BringWindowToBack(0);
      GUI.UnfocusWindow();
 
 }
 
 function OnGUI () {
     GUI.Window (0, Rect(Screen.width/2 - 400, Screen.height/2 - 300, 800, 600), gameWindow, "");
     
     
 }
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 Eric5h5 · Mar 26, 2012 at 03:50 PM 1
Share

Not without seeing your code.

avatar image koo_04 · Mar 26, 2012 at 03:57 PM 0
Share

Heh that would help. I will edit the code in.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by raoz · Mar 26, 2012 at 04:51 PM

It looks like it doesn't get pressed, because it must be pressed the moment it is drawn, or something in this manner. GUI.RepeatButton works, however, because it can be already clicked. But GUI.RepeatButtun gives you "It worked" like every time it gets drawn or so, so very often. There might be a better solution, but I cannot see one.

Comment
Add comment · Show 1 · 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 koo_04 · Mar 26, 2012 at 05:00 PM 0
Share

I was thinking that it was pressed as soon as it came up as well. There is a load time. Now that I can look at it, I will try just putting them in front of a GUI.box. See if I get the same issue. I really would like it in a window so I can show and hide the window as I need.

avatar image
0

Answer by Bunny83 · Mar 26, 2012 at 05:23 PM

Remove those two lines:

 GUI.BringWindowToBack(0);
 GUI.UnfocusWindow();

You unfocus the window every frame. You can never use any GUI element in the window this way.

Comment
Add comment · Show 1 · 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 koo_04 · Mar 26, 2012 at 05:26 PM 0
Share

Except I added those htat way you cant focus on the window itself. $$anonymous$$aybe I should remove the BringWindowToBack?

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

6 People are following this question.

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

Related Questions

How do I draw controls in a GUI Window - based on screen dimensions? 2 Answers

Dragging and Locking Buttons. 1 Answer

Add EditorUI elements when a button is pressed 0 Answers

GUI Button and Window 1 Answer

A few GUI related questions. 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