Created
September 9, 2021 00:58
-
-
Save AldeRoberge/e94f786a3e84ce74d79c95cfd19ac4c8 to your computer and use it in GitHub Desktop.
Resets an Unity tilemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace Scripts | |
{ | |
public class MapReset : MonoBehaviour | |
{ | |
public Terrain terrain; | |
private float[,] originalHeights; | |
private void OnApplicationQuit() { | |
this.terrain.terrainData.SetHeights(0, 0, this.originalHeights); | |
} | |
private void Start() | |
{ | |
this.originalHeights = this.terrain.terrainData.GetHeights( | |
0, 0, this.terrain.terrainData.heightmapResolution, this.terrain.terrainData.heightmapResolution); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment