When using procedural tools, usually think about runtime generation (i.e. while the player is playing), but we can obviously also pregenerate things such as heightmaps or bitmaps, which is why I am sharing this simple script that allows writing arrays to textures and writing these textures to disk.
When using this script, there are a few things to keep in mind:
We’ll be writing texture files to the Resources folder. Remember that files in the Resources folder are loaded with Resources.Load, and are not loaded by default. This is useful if you have, say, a single actual play scene with a terrain on which you are applying a heightmap and textures; you don’t need all your pregenerated textures loaded in memory if you’re only using one!
The Resources folder is deprecated by Addressables, but you can still use it.
Textures written to disk might not be immediately available/shown in the editor; you’ll likely have to refresh the asset database manually or by using the AssetDatabase.Refresh function.
Anyway here’s a (tentative) first draft for this utility script.