Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bone References Seemingly Lost in Build when Reloading Scene

Discussion in '2D Experimental Preview' started by stalwarttom, Dec 24, 2019.

  1. stalwarttom

    stalwarttom

    Joined:
    Nov 7, 2018
    Posts:
    3
    I've been working on a brawling game that uses the 2D Animation system for the characters as well as the PSD importer to import characters as PSB files. In our game, character prefabs are instantiated at the start of the game (when the level scene is loaded). While everything works fine in the editor, issues arise when playing in a build. The first playthrough of a level works fine, but then after reloading the level scene from the main menu, the characters do not animate. I've tried monitoring the console in a development build and have resolved all of the errors that it showed, yet nothing has changed.

    The only clue I have is that the animations all have animation events in them that still trigger at the correct times, so the animations are still "playing", leading me to believe that reloading the scene has caused bone references to be lost in the sprite skin components in my prefabs. Does anyone have any experience or fixes for this?

    Thanks!
     
  2. stalwarttom

    stalwarttom

    Joined:
    Nov 7, 2018
    Posts:
    3
    So it turns out this was caused by Unity unloading the bone data when I unloaded the scene, but never reloading it when I tried to instantiate a prefab that required it. Strange that it never threw any errors...
    Fixed it by instantiating and disabling a copy of the prefabs that need to continue to exist in memory, which isn't the most clean fix.
     
  3. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Can you send in a bug for this issue with a simple repo project for us to look at?