Author Topic: Using UIWidget as container object?  (Read 3702 times)

pushxtonotdie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Using UIWidget as container object?
« on: September 23, 2015, 10:28:56 AM »
Hi,

I'm currently coming on board to an NGUI 3 project that was built in a way that I'm unfamiliar with. Its been a while since I've used NGUI as well. I was curious if its considered normal practice to 'nest' components now. In NGUI 2 putting widgets in widgets was a bad thing to do.

Additionally the developers are using the UIWidget class (aka not a subclass of UIWidget) on its own in the hierarchy to contain other objects. Is this a normal thing to do? Back when I used NGUI you would use Panels to contain other objects. Is UIWidget the new Panel?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using UIWidget as container object?
« Reply #1 on: September 26, 2015, 04:33:39 PM »
Yes, nesting is just fine and is often a good idea if you want to easily fade out something, as alpha is cumulative.

Using UIWidget on its own is also fine, as it's a blank invisible rectangle that is capable of receiving events if you put a collider on it.

UIWidget is not a new panel. Panel is what collects widgets and creates draw calls. UIWidget is just an invisible region that you can also use as a handy container. One example usage: making an interactable button that has a clickable region extending past its visible sprite.