Search Unity

Increase ref counter of a scene

Discussion in 'Addressables' started by Patrick_PS, Apr 6, 2020.

  1. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    [Unity 2018.4.18; Addressables 1.7.5]

    Since upgrading from 1.6.2 to 1.7.5 I have the following problem:
    - load addressable scene (additive)
    - set a game object as DontDestroyOnLoad in script
    - load another addressable scene (not additive)
    - all direct references (prefabs, sprites, ...) in the game object that was marked DontDestroyOnLoad become missing

    Is there a way to increase the addressable ref counter of the first scene without using LoadSceneAsync?
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Hey Patrick, I'll forward this to the team for them to take a look.
     
  3. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    Thanks.
    It would be good to know if this is working as designed.
     
  4. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    bump
    Do I need to start planning to remove all DontDestroyOnLoad uses from my project? Is this a bug that will be fixed in an upcoming update? Is there a workaround to keep the scene in memory?
     
  5. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Hey @Patrick_PS I think from the handle you get from that first scene load you did and call handle.Acquire(); and that should bump the ref count. Let me know if that doesn't work for you.
     
  6. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    Addressables.ResourceManager.Acquire(handle) did the job, thanks a lot. I was able to upgrade the addressables plugin to the newest version without issue.