Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Create scene asset from editor script

Discussion in 'Scripting' started by peaj_metric, Jan 8, 2021.

  1. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    145
    I would like to create a new scene asset file from an editor script.

    This is my current workaround but I would prefer not to open and close the scene but just to create the asset:

    Code (CSharp):
    1. var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
    2. EditorSceneManager.SaveScene(scene, "scene.unity");
    3. EditorSceneManager.CloseScene(scene, true);
     
    david-wtf, Bezoro, odaimoko and 2 others like this.
  2. david-wtf

    david-wtf

    Joined:
    Sep 30, 2021
    Posts:
    23
    @peaj_metric I know this is old, but did you find a solution?
     
  3. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    145
    No sadly only this workaround. The only other thing that comes to my mind would be to copy an existing (empty) Scene file or even use the file api to create a file and write the YAML code of an empty scene file into it.
     
    david-wtf likes this.