Why is Terrain SetHeights persistent? This means, that the terrain keeps the in runtime modified heights after stopped the game. Ok, maybe this is performance issue.
But how to reset the heights after runtime has been stopped?
I tried to hold the original heights with GetHeights of the whole map.
And onDestroy() of my script I SetHeights back. But this does not work?
Is there a option in Unity or an correct way to restore the terrain map?
The issue here is that the Terrain script doesn’t contain any terrain information. It just references a TerrainData asset which actually is an asset in your project. In a build game any changes to assets won’t be permanent as when the application is restarted they will be back to the state they are stored in the asset database. However inside the editor any changes to assets will persist.
If you want to avoid this, create an instance of the TerrainData object so the Terrain is working on the temporary copy
Keep in mind that if you have several Terrain instances which used the same TerrainData object, they will now each use their own object. Though it’s quite rare to actually have two or more Terrains with the same TerrainData.