Saving and Loading BlobAssetReferenced based Entities

The original goal was to use the SerializeUtility to save the world, stop the play state (quit game) and load the old world back in upon a restart or in game request. The problem I see at first glance is the entities I am wanting to save have components that have BlobAssetReferences in them, and it would seem that that data of the BlobAsset is lost. Due to the nature of the data itself it is desired to not switch away from using BlobAssets.

I might be missing something, but is there a way to save the BlobAssetReferences to a file using the SerializeUtility or will I need to handle it myself? Ideally it would be nice to be able to save only the relevant entities in a given EntityManager in a manner similar to SerializeUtility.SerializeWorld(EntityManager, writer, entitiyFilter) and then read them back into a world as it is now.

Example of a component tagged to an entity

public struct Component : IComponentData {
    public BlobAssetReference<Blob> BlobReference;
}

Just a heads up but BlobAssets in general cause a bunch of issues serializing at the moment (0.13). I’ve already reported this and QA were able to reproduce it and there is a public tracked issue here.

Note this specific issue doesn’t exist in 0.11 according to QA

I shall cast my vote on it

Hello,
Thanks for reporting, I’m going to look into it right away.

@Soaryn your issue may be slightly different than @tertle 's one. Do you mind to create a repro case, create an issue and give me the link so I can be sure yours is addressed too?
Thanks

Uh, it is less of an issue, more of a question. I unfortunately don’t have much in way of time to allocate submitting a repro, but the question more simply put: “How do you properly serialize entities in a world when they contain BlobAssetReferences in their component data?”

Well, in our case we don’t serialize BlobAssetReferences (BAR), as we build BARs at application start after getting everything required prefabs and configs from addressables, and because of this we don’t serialize BAR as they will be duplicated on deserialization, this is just how, currently, world (de-)serialization with blobs works, it’s not trying to merge blobs, but this is fine as I spoke with Simon and they plan some pre\postprocessors for serialization\deserialization, don’t know any estimations, but it’s in their mind and that’s good, until that we have our own pre\postprocessors for (de-)serialization, awe use that for saving\loading game, with our own unique ID system (which persistent in both - editor and runtime) we can just replace real component, which contains BAR, on serialization, to component with a unique ID to a prefab with the same BAR, and then back thing on deserialization, same with any managed things like meshes, materials etc.
Of course this solution suitable not for all cases, but in our case, this works pretty well.

1 Like