Author Topic: NGUI Instantiate create on center  (Read 2732 times)

outgoing

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
NGUI Instantiate create on center
« 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. }

outgoing

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: NGUI Instantiate create on center
« Reply #1 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  :)