Author Topic: Unity 4 - NGUITools.SetActive()  (Read 7067 times)

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Unity 4 - NGUITools.SetActive()
« on: November 14, 2012, 11:09:39 PM »
Is there any known problems with the latest NGUI and Unity 4?

My project uses NGUITools.SetActive() pretty heavily when a scene loads to enable and disable certain parts of the interface. In Unity 3.5 this is all good, but in Unity 4 it's like all of that code is just ignored. I had the same problem early on using the first betas.

Any ideas?

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #1 on: November 14, 2012, 11:13:18 PM »
I'm also still getting the same problems that I posted about here:

http://www.tasharen.com/forum/index.php?topic=1472.msg7613#msg7613

(there's a video in that thread showing the issue).

helioxfilm

  • Guest
Re: Unity 4 - NGUITools.SetActive()
« Reply #2 on: November 15, 2012, 12:19:56 AM »
From Unity changelog:


We have changed how the active state of GameObjects is handled. GameObjects active state will now affect child GameObjects, so setting a GameObject to inactive will now turn the entire sub-hierarchy inactive. This may change the behavior of your projects. GameObject.active and GameObject.SetActiveRecursively() have been deprecated. Instead, you should now use the GameObject.activeSelf and GameObject.activeInHierarchy getters and the GameObject.SetActive() method.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #3 on: November 15, 2012, 12:24:53 AM »
I believe NGUITools.SetActive() was added to work around problems with SetActiveRecursively(). So with these new Unity changes, should we go back to using the built in stuff or continue with NGUITools.SetActive()?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #4 on: November 15, 2012, 12:40:38 AM »
NGUITools.SetActive works exactly the same in Unity4 as setting gameObject.activeSelf. Be sure to grab the latest version though (2.2.6).

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #5 on: November 15, 2012, 12:54:20 AM »
Yep - running the latest NGUI. Just can't put my finger on why it's different under Unity 4 compared to 3.5..........

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #6 on: November 15, 2012, 01:04:10 AM »
In Unity 3.5 NGUI was disabling the entire hierarchy of game object. In Unity 4.0, NGUI only disables the top-most object (as it's now a cumulative state).

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #7 on: November 15, 2012, 01:08:25 AM »
Not entirely sure what you mean - so there's no way to disable the child objects at the same time now? It has to be done manually?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #8 on: November 15, 2012, 01:09:02 AM »
It's cumulative. As in, if a parent is disabled, the children are now automatically disabled.

stevej

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Unity 4 - NGUITools.SetActive()
« Reply #9 on: November 15, 2012, 01:11:34 AM »
So the end result should be the same... so, still not sure why what I'm doing works in 3.5 but not in 4 :)