Hi, I was wondering how I can swap a few game objects around with the parent/child method using javascript, while also using GUI to change the game objects around.
For example, I have a structure with a sphere, cylinder and a cube, and I was wondering how would I script it with javascript using GUI buttons to switch between the three objects?
little confused what you want
this might help
//fill ObjectList with the sphere, cylinder and cube
List<GameObject> ObjectList;
//this will be the a list of the names of each stored as a gui content to be
//displayed on each button
List<GUIContent> BaseEditorObjectsList;
void Start()
{
foreach(GameObject RawObject in ObjectsList)
{
Temp = RawObject;
BaseEditorObjectsList.Add(new GUIContent(Temp.name));
}
Width = 100 * BaseEditorObjectsList.Count;
Height = 30;
ListScreenRect = new Rect(0,0,Width,Height);
}
// Update is called once per frame
void OnGUI()
{
SelectedSpawnObject = GUI.SelectionGrid(ListScreenRect,SelectedSpawnObject,BaseEditorObjectsList.ToArray(),BaseEditorObjectsList.Count);
}
//this will give you a function to retrieve the selected object
public GameObject SpawnObject()
{
return (GameObject) ObjectsList[SelectedSpawnObject];
}