Author Topic: How do I re-parent in NGUI?  (Read 4259 times)

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
How do I re-parent in NGUI?
« on: September 29, 2013, 07:27:49 PM »
Now that I know NGUITools.AddChild adds a gameobject properly, I am curious how to migrate to a different parent.

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
Re: How do I re-parent in NGUI?
« Reply #1 on: September 29, 2013, 10:53:13 PM »
gameObject.transform.parent  = new parent object.transform

Is this what you were looking for?  This changed the current object's parent to a new one.

storm33229

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: How do I re-parent in NGUI?
« Reply #2 on: September 29, 2013, 11:24:20 PM »
gameObject.transform.parent  = new parent object.transform

Is this what you were looking for?  This changed the current object's parent to a new one.

Well, I use this one all the time... but I was curious if NGUI had a specific function for wrapping any special behavior it may want to do in addition to the re-parent.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do I re-parent in NGUI?
« Reply #3 on: September 30, 2013, 11:14:08 AM »
After reparenting like that, make sure to broadcast "ParentHasChanged" to the affected game object.