Change the default scene

Hi everybody.

My question is very simple : is it possible to change the default scene, and how ?

What I call default scene is the scene loaded when you make a “New Scene”, with a light and a camera.

Thanks for your help :slight_smile:

1 Like

No, there is no templates for scenes. But you can duplicate existing scene in project view. I usually have couple scenes like temp and Level_clean, and i just duplicate one of those rather than creating new scene.

2 Likes

Ok, thanks. Until now, I used to duplicate my scenes like you said, and it looks like I’ve to continue :confused:

I was looking to do this and found a way around it. It’s a bit hacky, but you can create a static class that gets initialized when the editor loads, get a callback when the hierarchy changes and search the hierarchy to see if it matches the default scene. From there you can clear the scene and load assets from whatever scene you want in.

[InitializeOnLoad]
public class MyScenePostprocessor
{
    static MyScenePostprocessor()
    {
        EditorApplication.hierarchyWindowChanged += ExampleCallback;
    }

    static void ExampleCallback()
    {
        List<GameObject> sceneObjects = new List<GameObject>(GameObject.FindObjectsOfType<GameObject>());

        // Does it match the default scene exactly?
        if (sceneObjects.Count == 2 && sceneObjects.Find(go => go.name == "Main Camera") && sceneObjects.Find(go => go.name == "Directional Light"))
        {
            string defaultScenePath = System.IO.Path.Combine(Application.dataPath, "Scenes/DefaultSceneOverride.unity");
            if (System.IO.File.Exists(defaultScenePath))
            {
                Debug.Log("Detected default scene - replacing with DefaultSceneOverride");
                EditorApplication.NewEmptyScene();
                EditorApplication.OpenSceneAdditive(defaultScenePath);
            }
        }
    }
}
3 Likes

That is a neat little hack. I like it.

For those around this post, there is a (new?) EditorSceneManager event called newSceneCreated that is a bit less hacky, but the concept is more or less the same

Here’s an example of how to modify the default scene.

using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[InitializeOnLoad]
public class NewSceneSetup : Editor
{
    static NewSceneSetup()
    {
        EditorSceneManager.newSceneCreated += OnNewScene;
    }

    private static void OnNewScene(Scene scene, UnityEditor.SceneManagement.NewSceneSetup setup, NewSceneMode mode)
    {
        Camera.main.backgroundColor = Color.black;
        Camera.main.clearFlags = CameraClearFlags.SolidColor;
        Camera.main.transform.position = Vector3.zero;

        var light = FindObjectOfType<Light>();
        if (light != null)
        {
            DestroyImmediate(light.gameObject);
        }

        RenderSettings.skybox = null;
        RenderSettings.ambientIntensity = 0f;
        RenderSettings.ambientLight = Color.black;
        RenderSettings.ambientMode = AmbientMode.Flat;
        Lightmapping.bakedGI = false;
    }
}
1 Like

There’s been a feature to make a custom default scene for years now. I think it might even have been around the last time this thread was posted in, four years ago.

Don’t necro posts in order to call people names over your misconception.

1 Like

We’ve had support for this since September 2019.

https://docs.unity3d.com/Packages/com.unity.scene-template@1.0/manual/index.html

Thread Locked.