so i’ve been using AssetDatabase.CreateAsset to save some data (in this case a Texture3D) at runtime from a script. i need to be able to save this asset, and will need to be able to save data in other ways in the future.
apparently, AssetDatabase does not work when you build the game, so you are supposed to use Resources instead. i can’t figure out what the equivalent tool would be to substitute CreateAsset, how can i save an asset to the Resources folder in a build?
oh ok, so do i have to have an external path somewhere to save all of the runtime information? what is the c# method for writing to an external file- i need to save a texture3d asset at runtime
But … you cannot create new assets. You can save a texture as an image at runtime and load it with ImageConversion.LoadImage() at runtime. But you cannot write a Texture(2D/3D) asset at runtime.
Unity has some kind of internal asset format for what you call a “3d texture.”
It will be what it is in Unity and nothing else. See the docs for details.
The code to create an asset in that format exists in the UnityEditor namespace.
That creation code will not be in a build.
If you wish to store the contents of what you call a “3d texture” you would need to serialize it yourself in some format, or else use some existing asset such as what you might find on the Unity asset store or on github.
If Texture3D is anything like Texture2D it will have a way to “get all bytes” in some kind of format (raw, png, whatever) that you can then save. And then recreate the texture from those bytes, or from an image (likely via ImageConversion class). Check the Scripting manual.