Author Topic: SetActive does not work  (Read 6251 times)

johnessy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
SetActive does not work
« on: May 18, 2012, 12:33:44 PM »
Hi guys just a quick question what am i doing wrong as i dont see what i am doing wrong.
I do have GameObjects set up and they have been assigned their GO's which is just panels from menus.

It also gets to the "End" Log

  1. void OnClick()
  2.     {
  3.         if (PhotonNetwork.connectionState == ConnectionState.Connected)
  4.         {
  5.             m_playerName = input.text;
  6.             Debug.Log(m_playerName);
  7.             Messenger.Broadcast("SetPlayerName", m_playerName);
  8.             NGUITools.SetActive(thisMenu, false);
  9.             Debug.Log("Beggining");
  10.             NGUITools.SetActive(nextMenu, true);
  11.             NGUITools.SetActive(nextMenu1, true);
  12.             NGUITools.SetActive(nextMenu2, true);
  13.             Debug.Log("End");
  14.         }
  15.     }

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: SetActive does not work
« Reply #1 on: May 18, 2012, 01:41:00 PM »
Could we see how the game objects are setup in the hierarchy view?

Aneurysm

  • Guest
Re: SetActive does not work
« Reply #2 on: May 20, 2012, 10:17:27 PM »
Are you assigning the GO's during an Awake function? If the objects are set to false (aka disabled) to begin with, then your GO's might not exist on assignment.

johnessy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: SetActive does not work
« Reply #3 on: May 22, 2012, 03:36:08 AM »
No i am not assgning them in the awake method. I am setting them in the inspector Also i have about 8 menus i need to switch between. Each menu is it's own i just enable/disable the panels but this does not seem to work. I need to be able to find a way to be able to switch between menus easily as some menus have about 20 buttons.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SetActive does not work
« Reply #4 on: May 22, 2012, 09:10:42 AM »
What do you mean by "setting them in the inspector"? Inspector? What does it have to do with SetActive? The code you posted reacts to OnClick, which has nothing to with the inspector.

You also need to enable the next menu before you disable the current object.

Oh and keep in mind NGUITools.SetActive is fully recursive, so if you have one menu parented to another, you will have odd results.