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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Any examples of LoadSceneInPlayMode

Discussion in 'Asset Bundles' started by lllelll, Feb 12, 2019.

  1. lllelll

    lllelll

    Joined:
    Feb 16, 2018
    Posts:
    2
    Hi all!

    Do anyone have an examples of EditorSceneManager.LoadSceneInPlayMode behaviour?

    I'm making "AssetBundle Loader Emulator" in Editor, to emulate a scene load from asset bundle, without add scene paths to "Build settings -> Scene Paths".
    I'm trying use this :
    Code (CSharp):
    1. EditorSceneManager.LoadSceneInPlayMode ("Bundles/Town/Town", new LoadSceneParameters (LoadSceneMode.Single, LocalPhysicsMode.None));
    I tried to use many variants of Scene path,
    but always Unity load scene "Town" without any objects and camera.

    Do anyone have any idea?
    Thanks!
     
  2. rmiha

    rmiha

    Joined:
    Sep 29, 2016
    Posts:
    8
    I have exactly same problem. LoadSceneAsyncInPlayMode works though.
     
  3. childcat

    childcat

    Joined:
    Apr 16, 2014
    Posts:
    3
    I have a problem like this too.
    Isn't there a solution?
     
  4. multimediamarkers

    multimediamarkers

    Joined:
    Feb 17, 2016
    Posts:
    49
    Any tips on how you solved this issue?
     
  5. fumobox

    fumobox

    Joined:
    Oct 19, 2014
    Posts:
    8
    This code worked fine.

    Code (CSharp):
    1. var guid = AssetDatabase.FindAssets($"{sceneName} t:scene")[0];
    2. var path = AssetDatabase.GUIDToAssetPath(guid);
    3. Debug.Log(path); // Assets/FooScene.unity
    4. EditorSceneManager.LoadSceneAsyncInPlayMode(path, new LoadSceneParameters(LoadSceneMode.Single));
     
    mahdi_jeddi and UNITY-Y6T65NAE like this.
  6. benbarefield-lighthaus

    benbarefield-lighthaus

    Joined:
    Sep 16, 2019
    Posts:
    7
    Using fumobox's solution I logged out the path of the scene I was trying to load and found that I had missed the "Assets/" at the beginning of the path I was trying to load.

    It seems that LoadSceneAsyncInPlayMode will just create a scene with the name you provide if there is nothing at the path you give it. Neat!