Author Topic: project structure with low-down UIpanels  (Read 3078 times)

KatieFish

  • Guest
project structure with low-down UIpanels
« on: June 08, 2012, 04:39:30 PM »
Hello!

I have the pro of unity and the paid version NGUI, using version 2.0.7c.

Here is my current structure.

UIRoot
--UICamera (Camera)
----UIAnchorLeft
------GameObjectWhichMovesAround1
--------VariousDecorationsNotInAPanel
--------GOSection1
----------UIPanel1 (with clipping)
------------UIGrids with prefabs in them
--------GOSection2
----------VariousDecorationsNotInAPanel
----------UIPanel2 (with clipping)
------------UIGrids with prefabs in them
------GameObjectWhichMovesAround2
--------VariousDecorationsNotInAPanel
--------GOSection1
----------UIPanel1 (with clipping)
------------UIGrids with prefabs in them (UIDragPanelContents with colliders and UICheckboxe)
----UIAnchorCenterEtc
------etc

This seems all well and good, and seems to work. After my last post i'm careful to check that there are not UIPanels anywhere that i do not want them to be.

I have UIPanels pretty far low on the grid. This is because i want them to keep their contents inside a small clipping area. Reading about UIPanels and performance, it seems as though you might recommend that i have UIPanels up on the level of GameObjectsWhichMoveAroundX however if i do that i expect it would cause trouble for my lower-down UIPanels which use clipping.

Another problem is that i have noticed that when i hit run, UIPanel is added to my UIRoot. That seems like it could be a problem for my lower-down panels as well, although at the moment i have not seen any ill-effects.

Can you help explain where UIPanels should go in my hierarchy given that i have several small places for menus that need to be clipped?

Thank you! =)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: project structure with low-down UIpanels
« Reply #1 on: June 08, 2012, 05:18:29 PM »
UIPanel gets added automatically if a widget can't find one above it when a widget gets added/instantiated. UIPanels can be used to separate geometry and improve performance. So if you have a spinning widget, and then a whole lot of text that doesn't change, putting the spinning widget on its own panel will drastically improve performance.

KatieFish

  • Guest
Re: project structure with low-down UIpanels
« Reply #2 on: June 08, 2012, 06:18:05 PM »
So do you expect the UIRoot level, automatically-added UIPanel to interfere with the lower-down UIPanels or not?

If i put a UIPanel on GameObjectWhichMovesAround1 for instance, wouldn't that bother the UIPanel1 (with clipping) down lower?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: project structure with low-down UIpanels
« Reply #3 on: June 08, 2012, 06:25:03 PM »
Since you need clipping in sub-panels, you will need an external panel that doesn't get clipped any way, so either way you'll have a panel there. It's fine.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: project structure with low-down UIpanels
« Reply #4 on: June 08, 2012, 06:42:12 PM »
If you put a UIPanel on your root, then Refresh() will not work since you have a camera in the panel's hierarchy. I would probably rather just put panels on your anchors, which means a few more draw calls, but nothing terrible. Alternatively, move the camera out somewhere else. :)