Welcome,
Guest
. Please
login
or
register
.
October 12, 2024, 03:04:40 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...
« previous
next »
Print
Pages: [
1
]
Author
Topic: Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right... (Read 5923 times)
terence
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...
«
on:
March 10, 2013, 11:12:59 PM »
I noticed this:
http://www.tasharen.com/forum/index.php?topic=2283.msg11378#msg11378
and also notes in the build about fixes, but it still doesn't work right for me because when I call NGUITools.SetActive, many of my widgets child objects (i.e. labels, sprites etc) don't get activated. I just update to 2.3.6 and the problem is still there.
If it matter any, the panel starts out disabled (i.e. all elements disabled).
Logged
terence
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
Re: Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...
«
Reply #1 on:
March 10, 2013, 11:22:30 PM »
This is how i 'fixed' it...in NGUITools..
static
void
Activate
(
Transform t
)
{
SetActiveSelf
(
t
.
gameObject
,
true
)
;
// Prior to Unity 4, active state was not nested. It was possible to have an enabled child of a disabled object.
// Unity 4 onwards made it so that the state is nested, and a disabled parent results in a disabled child.
#if UNITY_3_5
for
(
int
i
=
0
, imax
=
t
.
GetChildCount
(
)
;
i
<
imax
;
++
i
)
{
Transform child
=
t
.
GetChild
(
i
)
;
Activate
(
child
)
;
}
#else
// If there is even a single enabled child, then we're using a Unity 4.0-based nested active state scheme.
/*for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
{
Transform child = t.GetChild(i);
if (child.gameObject.activeSelf) return;
}*/
// If this point is reached, then all the children are disabled, so we must be using a Unity 3.5-based active state scheme.
for
(
int
i
=
0
, imax
=
t
.
GetChildCount
(
)
;
i
<
imax
;
++
i
)
{
Transform child
=
t
.
GetChild
(
i
)
;
Activate
(
child
)
;
}
#endif
}
Pretty much commented out the check which pops out of the method if it finds any 'active' children. The only thing that comes to mind is that some how an active child was found when there shouldn't be..
Logged
Nicki
Global Moderator
Hero Member
Thank You
-Given: 33
-Receive: 141
Posts: 1,768
Re: Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...
«
Reply #2 on:
March 11, 2013, 08:20:26 AM »
SetActive only sets the current gameObject as active (via activeSelf).
This is a different behavior than the old SetActiveRecursively.
If you need to set it active recursively do something like this
void
Activate
(
Transform t
)
{
SetActive
(
t
.
gameObject
)
;
for
(
int
i
=
0
;
i
<
t
.
childCount
;
i
++
)
{
Activate
(
t
[
i
]
)
;
}
}
Logged
terence
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
Re: Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...
«
Reply #3 on:
March 11, 2013, 10:29:25 PM »
Yes. I know that, but I am just pointing out that the NGUITools.SetActive should still work consistently across Unity3.5 and Unity 4..
I should either be included as a fix for the current build or improved upon so it does work consistently.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...
«
Reply #4 on:
March 12, 2013, 12:56:42 AM »
The way it works is quite correct. The goal of it is to disable a game object and all of its children. In Unity 3.5 this means disabling the game object and all the children individually. In 4.0 it means disabling only the topmost object.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Unity 3.5 -> Unity 4 NGUITools.SetActive still doesn't work right...