Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Loading the same scene twice, additively

Discussion in 'Scripting' started by Leniaal, Feb 5, 2021.

  1. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    Hi there,

    I'm working on a system for which I need to load the same scene twice. I've got it working at runtime using the addressables system and it seems to work fine:

    upload_2021-2-5_16-12-0.png

    But when I try to do this in the editor, the scene only loads in a single instance.

    Loads scene twice:
    Code (CSharp):
    1. Addressables.LoadSceneAsync(SceneToLoad, LoadSceneMode.Additive).Completed += sceneLoadCompleted;
    2. Addressables.LoadSceneAsync(SceneToLoad, LoadSceneMode.Additive).Completed += sceneLoadCompleted2;
    Loads scene once:
    Code (CSharp):
    1. scene = EditorSceneManager.OpenScene(AssetDatabase.GetAssetOrScenePath(SceneToLoad.editorAsset), OpenSceneMode.Additive);
    2. scene2 = EditorSceneManager.OpenScene(AssetDatabase.GetAssetOrScenePath(SceneToLoad.editorAsset), OpenSceneMode.Additive);
    Does anyone know how to load a scene twice in the editor? I would really like to find out.
     
  2. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,992
    My inclination would be to turn it into a prefab and to load that twice. Seems as if it would give better control over which object is in which "scene", through parents.
     
    lofell likes this.