Author Topic: Best NGUI hierarchy?  (Read 2895 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Best NGUI hierarchy?
« on: December 17, 2013, 05:17:00 AM »
Hello,

Small question, what do you recommend doing as a hierarchy for a window for example.
We can do multiple things such as :
1) Empty GameObject
- MyWindow (empty)
-- Background (sprite)
-- ScrollView
-- etc...

2) What you do in your videos
- MyWindow (the background sprite)
-- ScrollView
-- etc...

It seems that the second approach as the advantage with anchors, cause if I set an anchor on the scrollview, it will automatically be based on the background, which is not true for the first one.
But it seems weird to have a parent that is a background sprite... no ?

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Best NGUI hierarchy?
« Reply #1 on: December 17, 2013, 05:37:41 AM »
Also a disadvantage for the second method, it's if you want to change the alpha of the sprite, it will change also change the alpha of children :/

ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Best NGUI hierarchy?
« Reply #2 on: December 17, 2013, 05:51:29 AM »
That can be a big advantage as well, depending on what you need to achieve with certain UIs/UI elements.

There's no one 'best' solution for every case you come across. In our projects, we mix and match as necessary, and this is fine because everybody understands when we need to lay out our hierarchies in a particular way - they're not caught out by it. It's not something I'd recommend if people are less aware of what's going on with your UI, however.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Best NGUI hierarchy?
« Reply #3 on: December 17, 2013, 05:54:09 AM »
Yeah I think we should do per-problem, but I wanted to know if we can have a consistent solution across the project. I have my answer now :)

ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: Best NGUI hierarchy?
« Reply #4 on: December 17, 2013, 06:32:28 AM »
It's always tempting to have a general solution, but it's almost never the case. Unfortunately, life is too complicated for that. :)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Best NGUI hierarchy?
« Reply #5 on: December 17, 2013, 06:34:51 AM »
Ahah :)