- Home /
Proper way to save Terrain for save game feature?
I am working on a game (go figure) and am at the point where I need to start considering my load-save system. I got most of it figured out but I am discovering some things about the Unity Terrain and TerrainData that is making this more difficult.
My game has some features that include altering the terrain a lot (height changes, tree changes, layer alpha changes). When first testing these alteration in one of my scripts, I found that the terrain data stayed change after the runtime. As surprising as it was, I understood why since the terrain data is an asset.
Understanding this now there are a few ideas I have but dont know if they will work or are correct:
When a new game is started, make a copy of the terrain data asset, put it with the player data somewhere on disk, load the asset via script and assign to terrain.
Make a copy of the asset using the AssetDatabase and when the game is saved, copy the asset to the player data folder. On game reload, copy the file to
From my understand of the Assetdatabase, you cant copy anything into it from outside the Assets folder and should only be used for runtime asset loading, not management. And frankly I dont know what happens when builds are created in terms of bundling up these folders.
So the main question here is how are we as developers supposed to incorporate unity terrain into our save load mechanisms without altering the original assets?
Answer by jons1122 · Feb 23, 2021 at 09:48 PM
Hey! my way around this was Copying the the terrainData file with AssetDatabase.CopyAsset function. then you can use the copy of the terrain as the current one, or the other hand, depends on what you want.
Your answer
![](https://koobas.hobune.stream/wayback/20220613024409im_/https://answers.unity.com/themes/thub/images/avi.jpg)