help me to solve the problem.
i’m create game with many terrain. they are generated almost endlessly while the player scouts the map. and TerrainData should be saved to a folder with the saved name.
in unity i do it through AssetDatabase.CreateAsset(terrainData, path);
but when I build a project, I get error with AssetDatabase
how correct save terrainData in folder? or how create TerrainData for saving game?
In a built game all of the UnityEditor functions are gone, as they belong to the Unity editor binary itself.
Instead you would need to extract, serialize and save the data required to reconstruct the terrain however you want it, as with any other game runtime data.
Load/Save steps:
Don’t use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.
When loading, you can never re-create a MonoBehaviour or ScriptableObject instance directly from JSON. The reason is they are hybrid C# and native engine objects, and when the JSON package calls new to make one, it cannot make the native engine portion of the object.
Instead you must first create the MonoBehaviour using AddComponent() on a GameObject instance, or use ScriptableObject.CreateInstance() to make your SO, then use the appropriate JSON “populate object” call to fill in its public fields.
It’s more of a diorama than a game. and modifying is no problem. but I have to completely restore the landscape from the save