Best way to store readonly data on disk so it can be used in builds?

Lets say I have an array of floats as a field in a monobehaviour. I can use all the editor features to edit this data. Then I can create a blobassetreference so multiple threads can access this now read-only data concurrently. So far so good.

The final thing I want to do is store this blobasset on disk, and have a way to reference it so that I can access it from code and that it gets added to any builds I make. The gameobject and monobehaviour can then be excluded from the build entirely. I can not find an example of something like this though, is this available somewhere?

1 Like

I personally have folders of Json serialized data that I then deserialize on runtime and then reconstruct the blob assets.

It is tiresome but I already coded out an entire generic class, struct, and system that reads from hard drive, constructs the relevant assets, and returns an object or a reference. If I ever ship this, that’ll allow users to mod the fundamental data files without needing to download the source, download unity, then figure out how the interface and DOTS work.

BlobAssets can be serialized directly into a binary file, Unity has done that for you:

https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.BlobAssetSerializeExtensions.Write.html

Then reading it should be as simple as just using the Read method.