Search Unity

Addressables and DontDestroyOnLoad: objects losing connections on unload scene

Discussion in 'Addressables' started by dwit_mass_creation, Sep 16, 2019.

  1. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    74
    Test case:
    3 scenes: Init, TestScene, TestScene2
    Init loading scene TestScene and TestScene loading TestScene2 (load type: Single).
    TestScene has prefab with script setting it to Dont Destroy On Load.
    After loading scene TestScene2 object with Dont Destroy On Load is losing all connections: all script are missing and if there are references to objects in scripts they too are missing.

    Addressables config:
    pack1: TestScene
    pack2: TestScene2
    pack3: prefab

    If TestScene and TestScene2 are in same pack it is OK.
    How to handle loading and unloading multiple scenes with Dont Destroy on Load objects?

    [Edit] Unity 2018.4.9 and Addressables 1.2.3
     
  2. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    74
    I sent bug report (1184547).

    I assume that when addressable scene is unloading all dependent addressables are unloaded too when there are no active references to them. It seems that addressables are not tracking references to objects after DontDestroyOnLoad, so when I unload addressable scene all asset references in this object are unloaded too.

    Is this expected behaviour?
     
  3. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    Thanks for the bug report. It seems the reason why DontDestroyOnLoad won't play well with addressables.

    As a workaround, if you load asset then instantiate manually, will lead you unmanaged instances, then shall fix your issue.