Author Topic: Parenting NGUI widgets together  (Read 2207 times)

eyali

  • Guest
Parenting NGUI widgets together
« on: July 10, 2013, 09:01:10 AM »
Hi All,

I know it simple problem but it seems that I can't solve it. I have 3 UIButton and I want to group them all to make a prefab and attahced the prefab to the panel.

Any ideas?

Thank u in advace

Docteur Cox

  • Guest
Re: Parenting NGUI widgets together
« Reply #1 on: July 10, 2013, 09:33:14 AM »
I think your should just create a subpanel to group your widgets and set your main panel as parent to that panel.  :)

eyali

  • Guest
Re: Parenting NGUI widgets together
« Reply #2 on: July 10, 2013, 09:42:11 AM »
I'll give it a shot...thnx. But what about performance hit?

Docteur Cox

  • Guest
Re: Parenting NGUI widgets together
« Reply #3 on: July 10, 2013, 09:59:25 AM »
No idea, I'm fairly new to NGUI too, so you should wait for more experienced user to answer :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Parenting NGUI widgets together
« Reply #4 on: July 10, 2013, 12:56:11 PM »
Panel
- GameObject (prefab this)
-- Button 1
-- Button 2
-- Button 3

eyali

  • Guest
Re: Parenting NGUI widgets together
« Reply #5 on: July 17, 2013, 07:48:39 AM »
What do u mean by GameObject ? any gameObject can do it? say for example an empty?

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Parenting NGUI widgets together
« Reply #6 on: July 17, 2013, 12:15:46 PM »
eyali: That is correct, an empty GameObject.

Create the main panel as normal.
Create a new (empty) GameObject
Create 3 buttons, as children to that new GameObject.

In the Project window of Unity, create a new prefab and drag the new GameObject with those 3 attached buttons into the new prefab instance.

Then if you have different scenes with their own panels, you can still instantiate the prefab you've just created and get the same button layout everywhere (good for consistency across screens, which players like).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Parenting NGUI widgets together
« Reply #7 on: July 18, 2013, 03:12:08 AM »
Select a game object and hit ALT+SHIFT+N -- this adds a new child underneath. :)