Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Alex on May 14, 2012, 04:56:09 PM

Title: Injecting gameobject to ngui hierarchy
Post by: Alex on May 14, 2012, 04:56:09 PM
Hi,
I made and item from ngui and make a prefab from it. for example:
*Item  <--- Item.cs script attached here
**Button1
**Button2

CMenu.cs is my ngui hierarchy  menu which i want to add the Item to.

When i try to place this 'Item' in my ngui hierarchy , i do this (in my Item.cs):

Transform tmp = CMenu.instance.transform.Find("Camera/Anchor");
f( tmp!=null ){
   transform.parent = tmp;
        transform.localPosition = new Vector3( 10f,10f,0f);
}

when i run the code, the position of the item is change to a huge number and not 10f,10f,0f
how can i fix that?

Thanks

Title: Re: Injecting gameobject to ngui hierarchy
Post by: ArenMook on May 14, 2012, 05:18:32 PM
I don't see anything wrong with it, considering that you're resetting the local position after parenting the object. Check what other scripts you have on your item and see what they do.

Also, finding objects by name is generally a very bad idea. Use inspector-set references or singletons instead.