Search Issue Tracker

Fixed in 5.4.0

Votes

23

Found in

5.3.0f4

Issue ID

758692

Regression

No

Unloading a scene can destroy non-instantiated prefabs that are indirectly referred to by other currently-loaded scene

Assets Management

-

How to reproduce:
1. Open the attached project "UnloadSceneBug.zip"
2. Open and play Scene1
3. Left Mouse Click to the game view, it will load Scene2
4. LMC again and it will unload Scene1
5. Notice that message which was displayed by Scene1 disappears and the one in Scene2 is "success"

6. Build and run the project for standalone target
7. Repeat step 3 and 4
8. Notice that message which was displayed by Scene1 disappears and the one in Scene2 is "ndataRedirect was destroyed"

Note: By "indirect references" user means that an object in Scene2 contains a reference to a non-instantiated prefab X, and X in turn contains a reference to a non-instantiated prefab Y. After unloading Scene1, X remains valid, but Y disappears.

Comments (10)

  1. D28447ffd6fdb9d6bde473160583f93b?d=mm

    Denis159

    May 20, 2016 00:17

    have this problem Unity 5.4.0b17 (64-bit). I will download version 5.4.0b18
    I hope this is fixed

  2. 9ec76ed4a4a5f8464e31b38f292113d2?d=mm

    greggaming

    Mar 24, 2016 18:49

    I can reproduce this bug in Unity 5.3.2p2

    My game's "loading" scene deletes itself half a second after the "main" scene loads. All "main" scene prefab references are available for that first half-second, and then turn null.

    Calling "DontDestroyOnLoad(prefab)" successfully stops my prefab references from turning null. It's a decent stop-gap, but not ideal.

  3. 5f034ddb162f30821f067927da0e502b?d=mm

    rempelj

    Feb 10, 2016 05:24

    Fixed for me in 5.4.0b5

  4. 25399789d95801ad3c4494a74838b55b?d=mm

    Raffin

    Feb 08, 2016 04:30

    This issue is definitely still present, please re-open this.
    1 - Load base scene
    2 - Load scene B as additive
    3 - Second scene contains a resources.load call.
    4 - Unload scene B: Prefab is now missing from resources list and cannot be loaded until game is restarted completely

  5. 7486330cd089cacacca65b7089704498?d=mm

    dushanl

    Feb 02, 2016 23:02

    Note that I can still reproduce this bug in 5.4.0b4.

    Best workaround I could find is to immediately move any prefabs loaded with Resources.Load[Async] to a scene that never gets unloaded with SceneManager.MoveGameObjectToScene.

  6. Fa628cb16b7c93b84b4107d239cf501a?d=mm

    Nicolas1212

    Jan 27, 2016 17:33

    This doesn't reproduce in the editor for me (5.3.0), but every time when building either on Android or desktop. Amazingly frustrating trying to find the cause of this. Building isn't exactly rapid

  7. 5e3921ffdddd4458b1788c817ba38168?d=mm

    maxxa05

    Jan 26, 2016 17:03

    It would help if at least calling Resources.Load wouldn't return null. It seems it doesn't even try to reload the asset if it was deleted.

  8. 5e3921ffdddd4458b1788c817ba38168?d=mm

    maxxa05

    Jan 26, 2016 16:24

    I meant: Ran in the same issue in 5.3.1p3 for our game Kôna.

  9. 5e3921ffdddd4458b1788c817ba38168?d=mm

    maxxa05

    Jan 26, 2016 16:23

    Ran in the same issue in 5.3.1p3 Kôna. We load/unload scenes for houses and such and use prefabs for terrain tiles. As you can expect, the terrain chunks get deleted, and we got big holes where we should have a terrain tile. So yes, that's a BIG issue.

  10. 578eda10cd1c4e4cdcc82ce1ae3a0af5?d=mm

    llutman

    Jan 21, 2016 21:50

    Ran into this problem today using 5.3.1f1.

    1) Load SceneA
    2) GameObject prefab = Resources.Load("MyPrefab", typeof(GameObject)) as GameObject;
    3) yield return SceneManager.LoadAsync("SceneB", LoadSceneMode.Additive);
    4) SceneManager.UnloadScene("SceneA");
    5) GameObject prefab = Resources.Load("MyPrefab", typeof(GameObject)) as GameObject;

    After (2), the prefab variable holds a valid reference.
    After (5), the prefab variable is null.

    It seems like calling UnloadScene somehow destroys the prefab, and it can't be loaded again. This only happens on a device, it works fine in the editor.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.