Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: outgoing on March 11, 2014, 05:29:25 AM

Title: NGUI Instantiate create on center
Post by: outgoing on March 11, 2014, 05:29:25 AM
Trying to create a copy of the object (NGUI) through Instantiate. Debug.Log (copy.transform.localPosition); prominence (-181.0, 230.0, 0.0), although in fact created a sprite to be in (0, 0, 0). What am I doing wrong? NGUI latest version.

  1.  private void OnGUI()
  2.     {
  3.         if (GUI.Button(new Rect(10,10,100,50), "asdad"))
  4.         {
  5.             copy = Instantiate(gameObject) as GameObject;
  6.             Debug.Log(copy.transform.localPosition);
  7.         }
  8. }
Title: Re: NGUI Instantiate create on center
Post by: outgoing on March 11, 2014, 05:56:03 AM
The solution was found through ...
NGUITools.AddChild(transform.parent.gameObject,gameObject).transform.localPosition = chacheTransform.localPosition;
If there is a better way direct  :)