Serialized Data Missing in Addressables Asset Bundles Addressables 2.0

After upgrading my project to Unity 6 and Addressables version 2.3.1, serialized data within asset bundles is no longer being included or preserved during the build process. This affects GameObjects with attached MonoBehaviour scripts that store data in [Serializable] classes containing arrays or other complex structures.

Steps to Reproduce:

  1. Create a GameObject with a MonoBehaviour script that includes a [Serializable] class storing arrays or other serializable fields.
  2. Add the GameObject to an Addressables Group.
  3. Build the Addressables asset bundles using Addressables 2.3.1.
  4. Load the asset bundle at runtime and inspect the serialized data.

Expected Behavior: The serialized data within the attached scripts should persist in the asset bundle and remain accessible at runtime, even though the script reference itself is not included in the bundle.

Actual Behavior: The serialized data is missing or reset when the asset bundle is built using Addressables 2.3.1. However, the same data persists correctly in bundles built with older versions of Addressables (Addressables 1.22.3).

Workaround: Downgrading the Addressables package to version 1.22.3 resolved the issue. Asset bundles built with version 1 correctly include and preserve the serialized data.

Additional Information:

  • Unity Version: 6.0.0
  • Addressables Version: 2.3.1 (issue occurs); 1.22.3 (no issue)
  • Platform Tested: Windows

Example Code

[Serializable]
public class MySerializableData
{
    public string[] myStrings;
    public int[] myIntegers;
}

public class MyMonoBehaviour : MonoBehaviour
{
    public MySerializableData data;
}

I’m sure I just missed a step here, but I’m not able to reproduce the issue.

I used Addressables 2.3.1. I have a MonoBehaviour that refers to the data class. I have created a prefab with that MonoBehaviour and added it to an Addressables group. I have set values for the data class in the prefab instance in the scene.

I have added some debug to print out the values in the MonoBehaviour.

I switched the “Play Mode Script” to “Use Existing Bundles”. I build my bundles. I hit Play and see the expected values printed out. I’ve used webextract/binary2text to look at the bundles and I see my values serialized.

Where am I differing from what you’re doing?

Thank you for your response and for attempting to reproduce the issue. However, I’m still encountering the problem in my main project despite following the same steps.

Here are additional details and observations:

  1. Behavior in Other Projects:
    I tried replicating the same setup in a new project using Addressables 2.3.1, and the serialization works perfectly there. The MonoBehaviour and its associated [Serializable] data class retain their values after building Addressables, and the asset loads correctly at runtime.
  2. Main Project Issue:
    In my main project, which was initially created using Unity 2022 and an older Addressables version, the data is not getting serialized correctly after upgrading to Unity 6.0 and Addressables 2.3.1. Specifically:
    • The prefab loads with a “Missing MonoBehaviour” error, even though the script is present in the project.
    • This happens when I load the asset bundle created in the main project into another project where serialization works fine, indicating that the issue is during the build process.
  3. Previously Working Setup:
    Prior to the upgrade, the serialization worked flawlessly in the main project with Unity 2022 and an older Addressables version (1.22.3). After the upgrade:
    • I verified that the script (UserData) is still located in Assets/Scripts/Main/Runtime/UserData and is correctly assigned to the prefab.
    • I have not made any significant changes to the script or its location since upgrading.
  4. Troubleshooting Steps Taken:
    • I ensured that the prefab includes the serialized fields and that they are correctly populated before building Addressables.
    • I moved the UserData script to the root Assets/Scripts folder to rule out folder-specific issues.
    • I verified the prefab setup in the Addressable group, ensuring all dependencies are included.
    • Clearing and rebuilding the Addressables cache did not resolve the issue.

I’ve tried to create a reproduction case on my own and failed. Would you mind submitting a bug report?

How do I submit a bug report? – Unity Support Help Center