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

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?

4 Likes

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.

public static IEnumerator LoadSceneAsync(AssetReference _asset, LoadSceneParameters _params)
{
    var loadSceneAsync = Addressables.LoadSceneAsync(_asset, _params.loadSceneMode);
    yield return loadSceneAsync;
    var loadedScene = loadSceneAsync.Result.Scene;
    var newScene = CreateScene($"{loadedScene.name}.copy", new CreateSceneParameters(_params.localPhysicsMode));
    foreach (var rootGameObject in loadedScene.GetRootGameObjects())
    {
        MoveGameObjectToScene(rootGameObject, newScene);
    }
}

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.

2 Likes

Nice one thanks for sharing that.