I’m trying to do this :
They won’t give out the script, so I retyped the whole thing using wordpad. I don’t know anything about scripting and maybe I got some errors in there. I don’t know how to check that. The problem is I’m getting an error when adding the script to my terrain : “can’t add script component because the script class cannot be found…”The name of the script is the same (PaintTerrain) so that can’t be the problem.
Here’s the script :
using UnityEngine;
using System.Collections;
public class PaintTerrain : MonoBehaviour
{
[System.serializable]
public class SplatHeights
{
public int textureIndex;
public int startingHeight;
}
public SplatHeights[] splatHeights;
void Start()
{
TerrainData terrainData = Terrain.activeTerrain.TerrainData;
float[, ,] splatmapData = new float[terrainData.alphamapWidth,
terrainData.alphamapHeight,
terrainData.alphamapLayers];
for (int y = 0; y < terrainData.alphamapHeight; y++)
{
for (int x = 0; x < terrainData.alphamapWidth; x++)
{
float terrainHeight = terrainData.GetHeight(x,y);
float[] splat = new float[splatHeights.Length];
for(int i = 0; i < splatHeights.Length; i++)
{
if(terrainHeight >= splatHeights*.startingHeight)*
splat = 1;
}
for(int j = 0; j < splatHeights.Length; j++)
{
splatmapData[x, y, j] = splat[j];
}
}
}
terrainData.SetAlphamaps(0, 0, splatmapData);
}
}