Terrain Splatmap does not automatically update

Hi everyone,

I made a small editor script to edit the splatmap of my terrain. For some reason though, after my script runs, I need to “touch” the terrain splatmap with an editor tool before any of my changes show.

The sequence goes like this:

  1. My script runs
  2. No changes are reflected in the editor
  3. I paint a small patch using one of the terrain paint tools in the editor
  4. Then magically all of my scripts changes to the alpha map appear as well.

How do we force the terrain to update it’s splatmaps after we edit it? I’m accessing the splatmap via the project view btw.

The only way to edit splat maps from scripts is this function:

public void TerrainData.SetAlphamaps (int x, int y, float[,] map)

If you pass x=0, y=0, and map as an array of floats with the dimensions [width x height x numberOfSplatMaps], you can set all splat map data in one call.

Note that this is an undocumented function, and it may change in future releases. So, do not use it in shipping webplayer code, if you don’t want to risk your web players breaking in the future.

Thanks Jonas!

I’m just using this in-editor for some custom terrain tools, so I’m not too worried about using undocumented calls for now.