Author Topic: inactive buttons visible  (Read 8110 times)

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
inactive buttons visible
« on: November 15, 2012, 10:44:06 AM »
Hello,

I have this issue that there are buttons visible that are inactive. And the weirdest thing is that when I am not in play mode I still see these buttons in the scene view but they are not even in the hierarchy. Could someone please help me? If you need other information please ask but at this moment I do not really know what information I should supply.

Kind Regards,
Max Uijlings 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: inactive buttons visible
« Reply #1 on: November 15, 2012, 02:22:05 PM »
Restart Unity, update to 2.2.6, and make sure that if you only have one camera it's set to clear color.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: inactive buttons visible
« Reply #2 on: November 15, 2012, 03:57:49 PM »
I have updated NGUI to version 2.2.6 and restarted unity. What do you mean with setting the camera to a clear color? By the way in some scene's I have 3 camera's the normal main camera and 2 for my GUI. Is that a problem?

Kind Regards,
Max Uijlings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: inactive buttons visible
« Reply #3 on: November 15, 2012, 10:09:42 PM »
At least one camera must be set to clear color (the first camera to draw), or your screen buffer will never be cleared.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: inactive buttons visible
« Reply #4 on: November 16, 2012, 11:48:59 AM »
I am really sorry, but I have no idea what you mean with setting a camera to clear color. I do not see such an option.

I have been tracing what happens and where this strange behaviour occurs. I will explain a bit more of what I am doing. I have a couple menus stored in a singleton object. A pause-menu, a finished-menu, a settings-menu. When you hit pause, the pause-menu shows up and the pause-button disappears. That is ok and functions as to be expected. When you hit "settings" in the pause-menu the settings-menu is shown. When you run out of time the lose-screen comes up. Finally, when you complete the level in time the win-menu shows up. Pretty straight forward.

The strange thing is that the behaviour explained earlier (buttons remaining visible) only occurs when you win the game. In all other scenarios everything works fine. But when you finish and I disable the pause-menu it does not disappear.

When you finish in time, so when you win, you enter a BoxCollider with a "WinScript" on it. In this script I disable the menus that I do not want shown at that moment. I was wondering if it is a problem that I do this from an OnColliderEnter function on a normal 3D gameObject.

The following example shows how I deactivate buttons when "pause" is pressed:
  1. function OnClick (){
  2.         if (trigger == PauseTrigger.enum_OnRelease){   
  3.            Time.timeScale = 0;
  4.            GameState.pauseButton.SetActive(false);
  5.        
  6.         }              
  7.                        
  8. }

the following example is what I do when you finish in time:
  1. function OnTriggerEnter(collision : Collider){
  2.         Timer.stat_timeStarted = false;
  3.         YouWon();
  4.         UnlockLevel();
  5.         SaveHighScore();
  6.        
  7.        
  8. }
  9.  
  10. function YouWon(){
  11.         Time.timeScale = 0;
  12.         GameState.finishMenuPanel.SetActive(true);
  13.         GameState.pauseMenuPanel.SetActive(false);
  14. }

I hope you can tell me what I am doing wrong. :)

Kind Regards,
Max Uijlings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: inactive buttons visible
« Reply #5 on: November 16, 2012, 05:49:12 PM »
Well, first of all, use NGUITools.SetActive(gameObject, true/false) instead.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: inactive buttons visible
« Reply #6 on: November 19, 2012, 05:09:32 AM »
OK so I have changed what you told me to change. Unfortunately this did not change anything in the behaviour :s. It does gave me a new error message: "Destroying GameObjects immediately is not permitted during physics trigger/contact or animation event callbacks. You must use Destroy instead."

I will try to figure out what is going on and when I find out I'll let you know. In the mean time if you have any other suggestions they are more then welcome.

Kind Regards,
Max Uijlings 
« Last Edit: November 19, 2012, 05:27:29 AM by MaxUylings »

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: inactive buttons visible
« Reply #7 on: November 19, 2012, 06:05:31 AM »
Oké I believe I have solved the issue. What I did at first was that I tried to set the panel object to true or false. Now I changed it so that I set the children of the panel to true or false. It is not exactly what I wanted because it would have been cleaner if I could set the whole panel (parent) to true or false. But this does works the way I want. 

Kind Regards,
Max Uijlings

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: inactive buttons visible
« Reply #8 on: November 19, 2012, 06:14:55 AM »
Oké I was just going through your documentation to look for a better solution and I found the SetActiveChildren() function. I put this on my panel object of my pause menu and this gives me the desired result :D
Thank you for your help.

Kind Regards,
Max Uijlings