1
NGUI 3 Support / Positioning issues with NGUI Sprites on instantiated prefabs.
« on: April 07, 2014, 04:48:41 PM »
Hi I am trying to spawn an NGUI sprite (not a NGUI Unity2D sprite) only when needed. It for some reason normally spawns at (0,0,0) despite the prefabs set position. So I set it in code and then gets a really weird position as shown below in the picture. Here is the code used:

As you can see the code console itself says the code worked, but the inspector tells a different story. If I don't do anything it just spawns at center (0,0,0).
- NGUITools.AddChild (panel.gameObject, mobFollower); // Spawn and add to panel so it shows up in the scene on top
- spawnedMobs.Add (GameObject.FindWithTag ("follower")); // Add to list of spawned enemies for the current combat.
- Debug.Log ("Vector3 position of pfFollower (clone) was " + GameObject.FindWithTag ("follower").transform.position);
- GameObject.FindWithTag ("follower").transform.Translate (MOB1_POS); // Place newly spawned object at the correct spot on the screen.
- Debug.Log ("Vector3 position of pfFollower (clone) is " + GameObject.FindWithTag ("follower").transform.position);
As you can see the code console itself says the code worked, but the inspector tells a different story. If I don't do anything it just spawns at center (0,0,0).