Author Topic: UIPanel vs UIWidget container  (Read 3964 times)

ngui

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 29
    • View Profile
UIPanel vs UIWidget container
« on: February 13, 2014, 07:59:27 PM »
Just wanted to know the difference and use for both UIPanel and UIWidget container. I understand that a widget is in theory an individual UI element and a panel is a container, and that a UIPanel allows for clipping. But it seems a UIWidget can also be a container, and can in situation be easier to use with regard to hierarchy and alpha.

kittikun

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 46
    • View Profile
Re: UIPanel vs UIWidget container
« Reply #1 on: February 13, 2014, 09:19:26 PM »
I personally try to avoid using UIPanel, unless I need the additional geometry (which is actually pretty rare).

UIPanel will creates more drawcalls and probably a wasteful rebinding of common textures/shaders.
You can actually see the effects with the "Draw Call Tool"

For good practice, I use UIWidget as a container so NGUI can optimize the render calls internally.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel vs UIWidget container
« Reply #2 on: February 14, 2014, 05:17:53 AM »
Indeed. The fewer panels you have, the easier your life will be.

Although I generally suggest having separate windows on their own panels as it makes pushing them back and forward easier, and keeps their widgets' depths from mixing together.