Forum rules - please read before posting.

Addressables: Remember scripts and Local Variables not working properly upon scene change?

edited August 2021 in Technical Q&A

[Unity v2019.4.29f1 - AC v1.73.8 - Addressables v1.16.19]

Hi Chris!

I have recently switched to using Addressables for Scenes and, although I have had seemingly no big issues with setting it up and making sure I could switch between scenes, I noticed a few odd behaviours:

  • When going back and forth between scenes, the Remember scripts do not seem to kick in. E.g. If in a Scene I make a Sprite invisible, when I exit and go back in the room, the Sprite becomes visible again although it has a Remember Visibility script attached to it.

  • Scenes won't often properly load their Local Variables as manually provided in the Variables Manager.

Now, I noticed something I noticed about the second behaviour.

The game I'm working on starts in a "Start" scene (the only one stored in the "Built in Data", therefore not an Addressable asset), which is used to mainly load up other Addressable assets and, after making sure everything got imported correctly, manually changes to a given scene, using AC.KickStarter.sceneChanger.ChangeScene(sceneName, true);.

When I load a specific scene this way, apparently there are no issue in importing, at least, the Local Variables correctly. If, on the contrary, I simply switch from scene A to B using Scene: Switch ActionLists, it does not import them correctly.

Do you have any idea of what I may be doing wrong?

For context, my Settings Manager has:

  • Save asset references with Addressables? set to true
  • Reference scenes by: set to Name
  • Load scene asynchronously set to true
  • Load scenes from Addressables set to true

And my Scripting Define Symbols do include AddressableIsPresent.

Other than that, for the sake of completion, all my scenes are currently stored into a single Addressable Group named "Scenes", and all of them have a label named "scenes".

Thanks a lot in advance, as always.

Comments

  • How are you determining that the variables are not being loaded? Is this by viewing the Variables Manager at runtime, or the scene's logic failing? Is there a difference between switching to a scene for the first time, vs re-entering one?

    Can you share screens of your exact settings when using the Scene: Switch Action? So long as you reference scenes by name, that should fundamentally work the same as calling ChangeScene in the way you are through script.

    It does look like there is an issue with the loading of Remember script data, however. I shall look into this now.

  • edited August 2021

    Thank you!

    It's exactly what I do (and have always done, honestly - I haven't changed anything in my Scene: Switch Actions)

    What I have noticed is that the Local Variables values carry over between scenes. For instance, this is what I have in my "Start" scene:

    Next, here are the variables I manually set in a given scene:

    And finally, here is how the variables change when, from the Start scene, I move on to the other above-mentioned scene:

    This happens between each scene and it looks as if the variables from the previous scene try to take the place of those in the next one, relatively to their index.

    For instance, here the "SceneName" string variable has been changed to the float value of the variable that the previous scene had in the same index slot.

    I hope this helps!

  • Thanks - I'll look into it and let you know if I need more information.

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.