Hey,
I’am trying to texture my terrain trough script in runtime. My script does find “terrain toolkit” script and apply function perlingenerator and It does generate terrain again by pressing button, thats works fine. BUT I do also want texture it too and theres problems.
Terrain Toolkit’s example from documentation’s example
var go : GameObject = GameObject.Find("Terrain");
var slopeStops : float[] = [20.0, 50.0];
var heightStops : float[] = [0.2, 0.4, 0.6, 0.8];
var textures : Texture2D[] = [cliffTexture, sandTexture, grassTexture, rockTexture];
go.GetComponent("TerrainToolkit").TextureTerrain(slopeStops, heightStops, textures);
My script:
var slopeStops : float[] = [20.0, 50.0];
var heightStops : float[] = [0.2, 0.4, 0.6, 0.8];
var textures : List.<Texture2D> = new List.<Texture2D>();
function OnGUI ()
{
if (GUI.Button(new Rect(0,0,100,100), "Generate!"))
{
var TerrData : GameObject;
TerrData = GameObject.Find("Terrain");
TerrData.GetComponent("TerrainToolkit").PerlinGenerator(8, 0.27, 8, 1);
TerrData.GetComponent("TerrainToolkit").TextureTerrain(slopeTops, heightStops, textures);
//this just doesn't work..
}
}
I have been trying solve this myself for couple of days and can’t really figure it out… Help please this is just frustrating me