say if i want to create 10 objects.
i can do it by drag and drop ten prefabs into the scene view
or i can do it by making a script that automatically does it for me in game.
what i am looking for is sort of a hybrid between the two methods. i want to be able to use a script to create 10 objects and manipulate them in the scene mode. is it possible?
You can do that easily, by adding this line in your code, when you want to create it:
function CreateObjects(numberOfObjectsToCreate : int, objectName : String)
{
for(int i = 0; i < numberOfObjectsToCreate; i++)
{
GameObject go = new GameObject(objectName + i);
}
}
The code above will create how as many GameObjects with any name you want, plus a number whenever you call the function like this:
CreateObjects(10, "Cube");
When calling that function, it will create 10 objects with the names; Cube1, Cube2, Cube3 etc…
You can then access and edit them from the editor!
I think that’s what you are looking for.