Author Topic: UIRoot  (Read 4783 times)

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
UIRoot
« on: January 25, 2014, 08:04:24 PM »
I am just wondering if all of my GUI elements need to be under a UIRoot? If so, should they all share the same UIRoot? Or should there be only one?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIRoot
« Reply #1 on: January 26, 2014, 11:30:58 AM »
As long as you're not doing anything "funny" then yeah, they should be on the same root.

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: UIRoot
« Reply #2 on: January 26, 2014, 12:10:29 PM »
Can you explain why?

Also should the UIRoot be in the root of the hierarchy? Or does it not matter?

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: UIRoot
« Reply #3 on: January 26, 2014, 01:38:53 PM »
My game has different "modes" or "phases"...  I was organizing my hierarchy like this:

Phase 1
---Phase 1 Game
---Phase 1 UI

Phase 2
---Phase 2 Game
---Phase 2 UI

Phase 3
---Phase 3 Game
---Phase 3 UI

Then I would just disable and enable the root phase objects... I am running into a bug now and a UIRoot object is automatically getting created in the root of my hierarchy when I switch to my first phase. So this is what got me wondering about how my UI should be set up. What would generate a UIRoot object on its own? What is even the purpose of the UIRoot?

I'm wondering if I should organize like this:

Game
--- Phase 1 Game
--- Phase 2 Game
--- Phase 3 Game

UI
--- Phase 1 UI
--- Phase 2 UI
--- Phase 3 UI

Does it even matter?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIRoot
« Reply #4 on: January 26, 2014, 09:12:48 PM »
You can have more than one root. If your UI is a mix of 3D and 2D UIs for example, then you will most certainly have two roots.

If your UI is just 2D, or just 3D, then one is more than enough. Instantiate prefabs underneath your root instead of having multiples.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIRoot
« Reply #5 on: January 27, 2014, 09:10:30 AM »
The reason being ease of use. UIRoot sets up the scale for the rest of the UI, so if you have multiple roots, you'll have more places to screw some setting up like the manual height. :)

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: UIRoot
« Reply #6 on: January 27, 2014, 09:39:13 AM »
Thanks guys!