Author Topic: Uiwidged children best practice  (Read 3329 times)

corax

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Uiwidged children best practice
« on: January 12, 2014, 05:28:17 AM »
Hi guys,

In these days I'm switching old projects from 2D toolkit to NGUI and I need some advices. My GUI structure is really simple: I have a couple of View (menus if you want) with some children underneath like buttons labels and stuff. The View is linked to a mediator that will capture a group of events and notify the View about them.

Now children needs to be notified by the view when something happens. I don't think that dragging in the editor each label, button and etc.. in a View field (array or list) is a viable solution because sometime you forgot one, or delete one and things will break. I was thinking of FindComponentinParents<T> to let each widget register to the proper view field and from there let the View handle the events notification.

Anyone has experience with this kind of structure? Am I overthinking it?

 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Uiwidged children best practice
« Reply #1 on: January 12, 2014, 05:44:19 PM »
NGUI already has an event system. I would suggest you make use of it instead of trying to build your own. All widgets can receive events, provided you give them a box collider. Just watch the NGUI tutorials, it's quite simple.