Search Unity

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

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice

Addressables don't use LoadSceneParameters, don't allow local physics scenes

Discussion in 'Addressables' started by Daerst, Mar 18, 2020.

Thread Status:
Not open for further replies.
  1. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    The changelog states the following (one year ago):
    LoadScene API now takes the LoadSceneParameters that were added to the engine in 2018.2

    Addressables.LoadSceneAsync
    takes a
    loadSceneMode
    , but not not a
    localPhysicsMode
    (i.e. not using the full LoadSceneParameters). This way, Addressables are not a feasible alternative to regular SceneLoading right now.

    This is probably a super-easy fix, just handing the parameters instead of just the LoadSceneMode down the chain to the SceneProvider and whatnot. When can we expect it?
     
  2. TheDelhiDuck

    TheDelhiDuck

    Joined:
    Aug 29, 2014
    Posts:
    29
    As a work around. I ended up loading the the scene using LoadSceneAsync. Then created an empty scene with LocalPhysics enabled. Then I move all root objects from the scene into the new scene. Seems to work ok.
    Something like this.
    Code (CSharp):
    1. public static IEnumerator LoadSceneAsync(AssetReference _asset, LoadSceneParameters _params)
    2. {
    3.     var loadSceneAsync = Addressables.LoadSceneAsync(_asset, _params.loadSceneMode);
    4.     yield return loadSceneAsync;
    5.     var loadedScene = loadSceneAsync.Result.Scene;
    6.     var newScene = CreateScene($"{loadedScene.name}.copy", new CreateSceneParameters(_params.localPhysicsMode));
    7.     foreach (var rootGameObject in loadedScene.GetRootGameObjects())
    8.     {
    9.         MoveGameObjectToScene(rootGameObject, newScene);
    10.     }
    11. }
    12.  
     
    Last edited: May 29, 2021
  3. schetle

    schetle

    Joined:
    Nov 11, 2018
    Posts:
    1
    I tried this workaround, and it worked, so thank you for that.

    I wasn't satisfied that this workaround has to exist, so I embedded Addressables in my project and made the localPhysicsMode changes myself -- adding a LocalPhysicsMode parameter to the Addressables.LoadSceneAsync call. Here's the gist to patch Addressables in your own project, if you choose to do so:

    https://gist.github.com/schetle/64369e9c25c87b738b1de7eac4391b4a

    As I continue to work on it, I will update the gist as I pull in new versions of Addressables.
     
    Daerst and TheDelhiDuck like this.
  4. TheDelhiDuck

    TheDelhiDuck

    Joined:
    Aug 29, 2014
    Posts:
    29
    Nice one thanks for sharing that.
     
Thread Status:
Not open for further replies.
unityunity