Forum rules - please read before posting.

Suggestion: Scenes as addressables

edited April 2021 in Technical Q&A

Hi there,
Since we all want faster start-up-times and consoles are super picky about this issue, it seems to me that AC might help developers packing and loading scenes using addressables like Unity suggests here:

In the video only one scene (Initialization) is registered in the build settings, were a loading anim could be shown. From there scenes could be loaded on-demand, or all scenes could be loaded in bulk before any of the "real" scenes are shown to the player.

Loading scenes on-demand would be great during dev since I figure it would speed up the dev cycle (which I consider AC's biggest drawback), and bulk load would be perfect when doing a proper publish.

Might this be something you would consider for AC? I ask because if not I'll probably need to roll my own (which could be tricky since it would probably need to change the way AC references scenes when loading them).

Thanks

Comments

  • The issue at the moment is that AC internally refers to scenes by build-index - even if you reference them by name in Action fields.

    For scenes to be loaded from addressables, without a build-index, this would have to change.

    Co-incidentally, this is exactly something I've been looking into as part of the next update.

    I still expect the act of extracting scenes by addressable to be handled by custom script, but the addition of an option to refer to scenes by name, rather than index, should make the process relatively smooth.

  • edited April 2021

    Interesting, I'll postpone this effort until your next update.

    Yes, something like an interface I can implement to let AC ask for the scene to load (by name) would be great 👍

  • edited April 2021

    I've ran into the issue trying to load the scenes from asset bundles.
    It worked but then the savegame loading fails because the index of the scene is wrong (it's stored in the save file as -1 since it's not in the build).

    T_T

  • Indeed - I've outlined this above.

    The option to refer to scenes by name, as opposed to build index, will be provided as part of the upcoming v1.73.7 update.

  • Congrats on the v1.73.7 release! All my tests runs fine on it.

    So with the new release, is there any way to intercept the request for a scene along the lines that I suggested (or some other way)?

    Thanks!

  • edited May 2021

    So long as the scene has been "downloaded" from the Addressable in advance, it should be visible to AC from then on. It's then a case of ensuring that the correct scene is present in advance of AC wanting to load it.

    When are you looking to retrieve the scene Addressable? At the moment AC is about to switch to it?

    With Unity's Synchronous Worfklow, it should be possible to hook into the OnBeforeChangeScene event to extract the next scene before AC requests it.

    This event does not currently give you the next scene as a parameter, but that can be added if testing proves fruitful. As a quick hack, try switching to a fixed scene so that you know which Addressable to extract, i.e.:

    using UnityEngine;
    using AC;
    
    public class SceneAddressableTest : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnBeforeChangeScene += OnBeforeChangeScene; }
        private void OnDisable () { EventManager.OnBeforeChangeScene -= OnBeforeChangeScene; }
    
        private void OnBeforeChangeScene ()
        {
            // Load a specific scene Addressable here
        }
    
    }
    
  • I was thinking about the two loading strategies I mention in the first post. And see the second post for a suggestion on how AC would get hold of the scenes.

    Unless I'm mistaken, what you're suggestion would only work providing the "path" AC would use to reference the scene would be predictable (which I assumed it wouldn't be). But I know too little about addressables at this point to be sure.

  • edited May 2021

    If your addressables match the names used by AC (scenes can be referenced either by filename or path + filename), I don't see an issue. This is just a test, though - we can see about adding a parameter to the event to let you know the next intended scene name if things work.

  • Hi, sorry if I write in your discussion; is it possible for you to create a tutorial how to use addressable in an AC project? how create directory and to do loading scene to use addressable and asset bundle in AC :smile: thanks! (for to don't make mistake when we generate the project)

  • edited May 2021

    The exact approach you take regarding addressables will vary with the needs of the project, but I should like to provide an add-on script as an example of one method.

    It may, however, need some further tweaks to AC before this becomes possible. I am looking into this, but the above testing is also geared to help with that.

  • I'm struggling ringt now to finish the beta for the second act of my game, and I won't have time to look at addressables for a while I'm afraid. But I would be happy try out any examples anyone might come up with until then 👍

  • I've been looking into them, and unfortunately it's not possible to load in a scene as a regular addressable asset file - it has to be loaded as a scene directly.

    What you can do at the moment is place a scene in an Asset Bundle, then make that an Addressable, and then load that before AC calls the scene. This is a bit convoluted though.

    For proper integration though, it probably does make sense to have this officially embedded in AC - with scene names entered into Actions etc treated as Addressable names that then get loaded seamlessly.

    Anyone who'd like to be involved in testing: please PM me.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.