- Home /
Deleting terrain splatmap through scripts.
Is there a way to delete/remove the Unity terrain's splat-map data through scripts?
I am using C# to write an automated terrain generator for my game, currently working on auto-splatmapping part of the system.
I have successfully created splatmaps using this. http://docs.unity3d.com/ScriptReference/TerrainData.SetAlphamaps.html
But how do I remove splatmaps? I can't seem to find any solutions for this yet.
Answer by hanni6al · Apr 06, 2016 at 02:03 PM
This is a old question but I answer it nevertheless.
I do it the following way:
void OnApplicationQuit()
{
Ground.terrainData.splatPrototypes = null;
}
Which will called when the application quits.
I just tried that, and wow, it removed all my textures assigned to the terrain!
I guess making this non-destructive is easy, by first saving all the splat, null them, then re-assign the textures to the terrain.
However, this is not exactly what I need as it doesn't exactly remove the splatmap from the terrain asset data.
I am in need of a way to remove all of them entirely just like new terrain, no SplatAlpha in the terrain asset file.
I need this because when generating over 4 textures, it generates an extra splatmap. (And this somehow is never removed even when I have 4 or less textures).