Search Unity

Serializing the CompatibilityAssetBundleManifest

Discussion in 'Asset Bundles' started by nilsdr, Feb 13, 2020.

  1. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Hi,

    We have a functioning in production implementation of the assetbundle mechanism which heavily relies on there being a manifest object which contains all bundle hashes and dependencies.

    I've been working on rewriting this tool to use the scriptable build pipeline instead by generating a CompatibilityAssetBundleManifest object which should in theory be (mostly) the same functionally.

    There is no longer by default an assetbundle containing a manifest scriptable object, but instead a YAML containing this info. As I'm not sure how this YAML can be deserialized at runtime, I convert the CompatibilityAssetBundleManifest to JSON using the built in JsonUtility like so:

    Code (CSharp):
    1. File.WriteAllText("manifestlocation", JsonUtility.ToJson(manifestObject));
    Loading this at runtime works just fine but it appears the hash field is always empty. Is this expected? How am I supposed to load the compatability manifest at runtime? Do I run a separate build command to pack it in an assetbundle manually? Is there a way to deserialize from YAML that i'm missing?

    Code (CSharp):
    1. {"m_Keys":["material_cat_project_1","texture_cat_project_1","Cube","project1","animation_cat_project_1","sound_cat_project_1","font_cat_project_1","so_cat_project_1","material_cat_project_2","texture_cat_project_2","animation_cat_project_2","sound_cat_project_2","font_cat_project_2","so_cat_project_2"],"m_Values":[{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/material_cat_project_1","m_Crc":1540120958,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/texture_cat_project_1","m_Crc":4007275580,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/Cube","m_Crc":3392332976,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/project1","m_Crc":2054849325,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/animation_cat_project_1","m_Crc":1741419220,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/sound_cat_project_1","m_Crc":2602999497,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/font_cat_project_1","m_Crc":1172829958,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/so_cat_project_1","m_Crc":1250670448,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/material_cat_project_2","m_Crc":747736885,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/texture_cat_project_2","m_Crc":1489003589,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/animation_cat_project_2","m_Crc":3730864666,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/sound_cat_project_2","m_Crc":2143948711,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/font_cat_project_2","m_Crc":4010366920,"m_Hash":{},"m_Dependencies":[]},{"m_FileName":"/Users/xxxxxxx/Desktop/NetworkingLocalDev/contentoutput/2019.3.1f1/1/Android/so_cat_project_2","m_Crc":4071675840,"m_Hash":{},"m_Dependencies":[]}]}
     
    Last edited: Feb 13, 2020
  2. sbinter_levelex

    sbinter_levelex

    Joined:
    Jul 5, 2018
    Posts:
    9
    The Hash128 cannot be serialized and so you'll see there's no result. Our workaround was to create a class for the manifest that contained this data with a string replacement, then serialized and deserialized our custom class and converted that to the CompatibilityAssetBundleManifest after deserializing the custom version.

    Bit of a roundabout fix but seems to work correctly. We also had to do a separate build for a single bundle that included the manifest.
     
    nilsdr likes this.