Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: yanebra on June 01, 2013, 05:25:41 AM

Title: Instantiate Issue
Post by: yanebra on June 01, 2013, 05:25:41 AM
Hi,

I have a problems here,

I have three UIsprite in the Panel under the UIroot.
Once the sprite has been clicked, I scripted it to instantiate another sprite to replace it,
however, the new generated sprite will be created out of the UIroot in the hierachy.
How can I solve it, to make the new sprite appear under the UIroot?
I have checked in this forum, but I really cannot understand, (a newbie in coding)
Please give a help hand.

Many Thx
Yan
Title: Re: Instantiate Issue
Post by: dlewis on June 01, 2013, 07:29:20 AM
Either set the parent of the new sprite directly (newSprite.transform.parent = theParent) or use the AddChild function in NGUITools (I believe)
Title: Re: Instantiate Issue
Post by: yanebra on June 03, 2013, 06:09:11 AM
Re: dlewis

Thank you very much, by your guide I have tackled it.

for others who may have same question FYR.

var Parent: String;
var theChild: GameObject;

NGUITools.AddChild(GameObject.Find("Parent"), theChild));