Search Unity

Custom Mesh Assets Serialization Suggestion

Discussion in 'Editor & General Support' started by einWikinger, Feb 2, 2017.

  1. einWikinger

    einWikinger

    Joined:
    Jul 30, 2013
    Posts:
    97
    We're running into some performance problems with the Editor. The reason is, we have lots of custom Mesh assets stored in the AssetDatabase and our Project serialization mode is "Text only".
    To be clear, we create custom Mesh objects and then create an asset from it through AssetDatabase.CreateAsset(). The Meshes are very complex (high vertex count, many blendshapes, ..., serialized assets around 1.5MB) and thus the resulting text assets YAML is very - YAML parser unfriendly I guess (loading those meshes in play mode takes ages).
    From looking at the YAML representation of a Mesh object, not very much is gained from serializing it as Text as there is still lots of encoded binary data present that is not very diff/merge friendly. Aside from the questionable usefulness of merging or diffing Mesh assets.

    For custom ScriptableObjects, the PreferBinarySerialization attribute already exists to exactly circumvent these problems. My suggestion would be to have Unity serialize Mesh assets always as binary or, if there really are use cases for meshes-as-text, maybe have an option for it to serialize as text.
    If I missed any workaround to have binary mesh assets (switching the project to binary serialization is not an option), I'll embrance any suggestion!

    (Unity 5.5.0p3)
     
  2. einWikinger

    einWikinger

    Joined:
    Jul 30, 2013
    Posts:
    97
    Workaround: Create custom ScriptableObject asset with PreferBinarySerialization, then add all the meshes as sub-assets to that asset. Asset file will be binary serialized, but grows big. But loading times in editor improved by a factor of 100 in our case.
     
  3. popMark

    popMark

    Joined:
    Apr 14, 2013
    Posts:
    114
    Thanks for posting your work around, I was having a similar issue
     
    einWikinger likes this.