hi, fairly new to unity and i am trying to create a GUI for whenever I Instantiate a gameobject. I am instantiating 3 gameobjects and have them create a gui, each one moving over 300 in the screen width arg. I use a global variable in another script to set the screenwidth position and i know that it updates by 300 every time i create a clone but the new gui is created in the same position as the last one, over top of it.
the GUI that is attached to the Prefab is
var GUIposX : int = spawner2.enemyGUIposX;
var GUIposY : int = spawner2.enemyGUIposY;
function OnGUI() {
GUI.Box (new Rect (0, 150, 50, 50), "WPs: " + WP);
GUI.Box (new Rect (0, 200, 150, 50), "waypoint #'s: " + waypointC.Length);
GUI.BeginGroup(new Rect(GUIposX, GUIposY, 300, 500));
GUI.Box (new Rect(0, 0, 150, 50), "Enemy " + spawner2.nameInt);
GUI.Box (new Rect(0, 50, 150, 50), "Cur WP: " + currentWP);
GUI.Box (new Rect(0, 100, 300, 50), "Target: " + target.x + ", " + target.z + ", " + target.y);
GUI.Box (new Rect (0, 350, 150, 50), "Magnatude: " + moveDirection.magnitude);
GUI.EndGroup();
}
not worried about the first two boxes, it is the GUI.Group that i want to keep offsetting.
the Awake updates the global variable enemyGUIpoxX which holds the number for the offset i want. +300 every time a new one is created.
function Awake(){
spawner2.enemyGUIposX = spawner2.enemyGUIposX + 300;
}
but like i said it just draws it ontop of the first one, then the third one over both of them. I have also tried this without “(new Rect just (Rect” with the same result.
is this the wrong way to add a new gui, is there a better way. Thanks for any help.