I’m relatively new to Unity. I’m playing with the LG Simulator which is a Unity project for autonomous vehicle simulation.
My goal is to automate the process of building out scenes with varying roads, buildings, etc and then export those using some of the LG tools to be used in 3rd party tools. My goal is not to build a scene that will be “played” or simulated within Unity. So if I instantiate a GameObject at runtime and it’s not saved it doesn’t help me.
More concretely, here’s an example of what I want to do:
- Create empty scene
- Place 100 prefabs at random locations in scene using a script
- Save scene so that if I re-open it those prefabs will still be in the scene
- Repeat 10 times
Clear? Is this possible? Standard Unity or a 3rd party script?
You could save a list of what prefab you placed where and load it again once you are out of playmode to recreate your runtime scene.
You mean save a text file with location information? How would I then load that data back into the editor?
Make your script run in the editor by marking it with this attribute: Unity - Scripting API: ExecuteInEditMode
Use custom editors to create custom buttons that do things in edit mode (Maybe like spawn a bunch of prefab instances?) Unity - Manual: Custom Editors
Create empty scene: Unity - Scripting API: SceneManagement.EditorSceneManager.NewScene
Create an instance of a prefab: Unity - Scripting API: PrefabUtility.InstantiatePrefab
Save current scene: Unity - Scripting API: SceneManagement.EditorSceneManager.SaveScene
Make a custom editor window with controls for your workflow: Unity - Manual: Editor Windows
2 Likes