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 Daniel Cazan 1 · Jan 09, 2011 at 04:50 AM · buttonwindowunresponsive

GUI Buttons unresponsive in new window

I know I must be doing something very silly since this seems to be working in other parts of my code but..

void OnGUI() { int win_height; int win_width; if (rdc_requestConfirm) { win_height = 60; win_width = 360; win_left = Screen.width - win_width - 25; win_top = 80;

         GUI.Window(2, new Rect(win_left, win_top, win_width, win_height), Show_ConfirmationWindow, "");     
     }

// more stuff }

 void Show_ConfirmationWindow(int winID)
 {
     if (!Confirmation_Pending())
     {
        // return;
     }

     int btn_width = 180; int btn_height = 30;
     int btn_left_1 = 0; int btn_left_2 = btn_width;


     GUI.BringWindowToFront(winID);
     GUI.FocusWindow(winID);       

     if (GUI.Button(new Rect(0, 0, 360, 60), "click")) { Debug.Log("click"); }

     GUI.UnfocusWindow();
 }

The new window shows up as desire, I can see the button, but when I click on it nothing happens. I've also tried it without setting the focus, with setting the focus in the OnGUI, I just can't seem to get it to do its click action. It does acknowledge that its clicked in the sense that the button changes its look for a moment (and then changes it whenever I mouse over it), just seems like it can't complete its self. I saw someone in the old forums with the same question from a few months ago but I can't seem to find anything with the solution.. So, am I being really silly? Should this be really obvious and I am missing it?

Comment
Add comment · Show 4
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 yoyo · Jan 09, 2011 at 06:20 AM 0
Share

Is it possible that another component with a lower GUI.depth is swallowing your input? Note that OnGUI for all your components will run in order by GUI.depth. I've had trouble with this, not sure if it's your problem though.

avatar image Daniel Cazan 1 · Jan 09, 2011 at 10:54 AM 0
Share

Hmm.. not sure - shouldn't setting the Focus Window to that winID right before checking the button deal with a potential problem like that? I do have other windows in the code but there are not visible ones in the same part of the screen as this one, at the time that this one is running anyway. (And this is the only ID 2 window)

avatar image lathomas64 · Jan 22, 2012 at 07:17 PM 0
Share

I have the same issue a gui.button in my gui.window won't recognize clicks.

avatar image tomekkie2 · Jan 21, 2014 at 11:42 AM 0
Share

I am getting the same effect, but on a draggable window. When making undraggable - the effect dissapears. - And not anymore after moving this line:

GUI.DragWindow (Rect (0,0,10000,10000));

to the end of the window function.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Daniel Cazan 1 · Jan 11, 2011 at 09:42 PM

I got it working - I moved the call to my window to the bottom of the OnGUI after everything else, and set the GUI.BringWindowToFront(winID); GUI.FocusWindow(winID);
after the call to the actual window creation. I am still not sure how the other windows were taking the focus away unless OnGUI processes everything before doing any of the actual displays / calls to the window functions.. but that seemed to work. As soon as I have some free time I'll start running experiments and maybe update this answer with the 'why' of why the solution worked.

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 shuvos3 · Apr 07, 2017 at 11:27 AM 0
Share

Still not working for me! :(

avatar image
0

Answer by Ouss · Jan 14, 2014 at 06:18 PM

It's because there is no focus on the window, if you are using multiple windows, you can set focus using GUI.FocusWindow(windowId). For my part, when using multiple windows having different buttons, I put a confition in the function that is creating the window, to check if the mouse cursor is on a window (Rect.Contains) then I set focus on that window.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A few GUI related questions. 1 Answer

Open window on button click 1 Answer

Add EditorUI elements when a button is pressed 0 Answers

Help with unresponsive function / if statement 1 Answer

Is there a reason a button (or key) would be unresponsive half the time? 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