Set TerrainData in Terrain Component

Hi Community!

How can you set the TerrainData in the Terrain component? I seem to be able to change the collider’s one, but not the actual rendered terrain!

Thanks in Advance!:smile:

Wait… Can you even do that?

Why should it not work?
In unity 3.5.7 Its working fine.

I can only change the terraindata in the collider, not the actual terrain.

For me its working fine.

Here is my test example (not looking good but proofing , that its working)

using UnityEngine;
using System.Collections;

public class Terraintest : MonoBehaviour
{
	
	public Terrain myTerrain;
	public TerrainData myTerrainData;
	float[,] heights;
	int yRes ,xRes;
	// Use this for initialization
	void Start ()
	{
		myTerrain = GetComponent<Terrain> ();
		myTerrainData = myTerrain.terrainData;
		heights = myTerrainData.GetHeights (0, 0, myTerrainData.heightmapWidth, myTerrainData.heightmapHeight);
		yRes = myTerrainData.heightmapWidth;
		xRes = myTerrainData.heightmapHeight;
	}
	
	// Update is called once per frame
	void Update ()
	{
		for (int y = 0; y < yRes; y++) {
			for (int x = 0; x < xRes; x++) {
				heights [x, y] = Random.Range (0.0f, 0.1f) /* + heights [x, y]) * .5f*/;
			}
		}
		myTerrainData.SetHeights (0, 0, heights);
		
		myTerrain.terrainData = myTerrainData;
		//myTerrain.Flush ();
	}
}
1 Like