Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

TerrainData

Namespace: UnityEngine

/

Inherits from: Object

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

The TerrainData class stores heightmaps, detail mesh positions, tree instances, and terrain texture alpha maps.

The Terrain component links to the terrain data and renders it.

Variables

alphamapHeight Height of the alpha map.
alphamapLayers Number of alpha map layers.
alphamapResolution Resolution of the alpha map.
alphamapWidth Width of the alpha map.
baseMapResolution Resolution of the base map used for rendering far patches on the terrain.
detailHeight Detail height of the TerrainData.
detailPrototypes Contains the detail texture/meshes that the terrain has.
detailResolution Detail Resolution of the TerrainData.
detailWidth Detail width of the TerrainData.
heightmapHeight Height of the terrain in samples (Read Only).
heightmapResolution Resolution of the heightmap.
heightmapScale The size of each heightmap sample.
heightmapWidth Width of the terrain in samples (Read Only).
physicMaterial The physic material used by TerrainCollider using this Terrain.
size The total size in world units of the terrain.
splatPrototypes Splat texture used by the terrain.
treeInstances Contains the current trees placed in the terrain.
treePrototypes The list of tree prototypes this are the ones available in the inspector.
wavingGrassAmount Amount of waving grass in the terrain.
wavingGrassSpeed Speed of the waving grass.
wavingGrassStrength Strength of the waving grass in the terrain.
wavingGrassTint Color of the waving grass that the terrain has.

Functions

GetAlphamaps Returns the alpha map at a position x, y given a width and height.
GetDetailLayer Returns a 2D array of the detail object density in the specific location.
GetHeight Gets the height at a certain point x,y.
GetHeights Get an array of heightmap samples..
GetInterpolatedHeight Gets an interpolated height at a point x,y.
GetInterpolatedNormal Get an interpolated normal at a given location.
GetSteepness Gets the gradient of the terrain at point <x,y>.
GetSupportedLayers Returns an array of all supported detail layer indices in the area.
RefreshPrototypes Reloads all the values of the available prototypes (ie, detail mesh assets) in the TerrainData Object.
SetAlphamaps Assign all splat values in the given map area.
SetDetailLayer Sets the detail layer density map.
SetDetailResolution Set the resolution of the detail map.
SetHeights Set an array of heightmap samples.

Inherited members

Variables

hideFlags Should the object be hidden, saved with the scene or modifiable by the user?
name The name of the object.

Functions

GetInstanceID Returns the instance id of the object.
ToString Returns the name of the game object.

Static Functions

Destroy Removes a gameobject, component or asset.
DestroyImmediate Destroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoad Makes the object target not be destroyed automatically when loading a new scene.
FindObjectOfType Returns the first active loaded object of Type type.
FindObjectsOfType Returns a list of all active loaded objects of Type type.
Instantiate Clones the object original and returns the clone.

Operators

bool Does the object exist?
operator != Compares if two objects refer to a different object.
operator == Compares if two objects refer to the same.