Author Topic: You should never nest widgets! Parent them to a common game object.......  (Read 7735 times)

skaale

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Hi NGUI community,

I'am building a native app with NGUI and Unity3d.
The problem is that the I get a "you should never nest widgets! Parent them to a common game object insted. Forcefully changing the parent."?? in my console and then
all my animated game objects jumps out of the nested groups. It is working until a restart Unity3d then my animated gameobject looses it hierarchy, and I have to put all my
 Gameobjects  back into the hierarchy every time a compiling my unity project. 

I have a Hierachy looking like this:

Gameobject--
  UIpanel--
   Gameobject(animated gameobjects)--
    text
     logo

I have a screenshot attached, hope it makes sense:-)

Best Regards
Daniel

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: You should never nest widgets! Parent them to a common game object.......
« Reply #1 on: February 04, 2014, 07:28:48 AM »
You are using some old version of NGUI and should update to the latest in the NGUI 3 cycle. NGUI 2 isn't supported anymore, it was deprecated a while ago.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: You should never nest widgets! Parent them to a common game object.......
« Reply #2 on: February 04, 2014, 07:00:10 PM »
Jeg kan se dansk i screenshottet! :P

Like ArenMook says, you need to update. For the old version, however, yes, it's required that widgets do not nest. Nowadays NGUI handles that more gracefully.

kitgui

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: You should never nest widgets! Parent them to a common game object.......
« Reply #3 on: February 04, 2014, 09:36:51 PM »
I nest Labels within a containing Sprite all the time. Is this a bad thing?
« Last Edit: February 04, 2014, 10:24:17 PM by kitgui »

skaale

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: You should never nest widgets! Parent them to a common game object.......
« Reply #4 on: February 05, 2014, 05:14:07 AM »
Hello again,

Jeps Nicki, jeg er pære dansk fra KBH, måske du kan hjælpe mig:-)

Hallo again,

I know I have the newest version on The HDD, but I started out with 2.7 version in this project and I have BiG problem regarding migrating to the newest version. This is the best version for my project because I use Vuforia SDK and I have problems with the Unlit shader. I get a black camera screen + weird text in my login, but not with the 2.7.

So is it possible to do something! about the
Nested group thing in 2.7  when using animation ? Is UIpanel a widget? I only use Gameobject and UIpanel in my hierarchy.
if so should I Go though the pain and update?

Best Regards
Daniel
 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: You should never nest widgets! Parent them to a common game object.......
« Reply #5 on: February 05, 2014, 02:45:09 PM »
Use a common game object as parent, don't nest widgets in NGUI 2.

Instead of:

Sprite
- Label

...do:

GameObject
- Sprite
- Label

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: You should never nest widgets! Parent them to a common game object.......
« Reply #6 on: February 06, 2014, 03:37:29 AM »
UIPanels are not widgets, widgets are UILabels and the different types of UISprites. UIpanels are responsible for drawing the collection of widgets under it in the hierarchy, so you are required to have your widgets under a panel if you want anything drawn on screen. NGUI forcefully makes a panel if it doesn't find one where it expects it, thoguh, so you might not notice.

The point is that sprites and labels should not nest within each other, because then it just breaks. (in the old version)