Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

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

Terrain

class in UnityEngine

/

Inherits from: Behaviour

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

Switch to Manual

Description

The Terrain component renders the terrain.

Static Variables

activeTerrainThe active terrain. This is a convenience function to get to the main terrain in the scene.
activeTerrainsThe active terrains in the scene.

Variables

bakeLightProbesForTreesSpecifies if an array of internal light probes should be baked for terrain trees. Available only in editor.
basemapDistanceHeightmap patches beyond basemap distance will use a precomputed low res basemap.
castShadowsShould terrain cast shadows?.
collectDetailPatchesCollect Detail patches from memory.
detailObjectDensityDensity of detail objects.
detailObjectDistanceDetail objects will be displayed up to this distance.
drawHeightmapSpecify if terrain heightmap should be drawn.
drawTreesAndFoliageSpecify if terrain trees and details should be drawn.
heightmapMaximumLODLets you essentially lower the heightmap resolution used for rendering.
heightmapPixelErrorAn approximation of how many pixels the terrain will pop in the worst case when switching lod.
legacyShininessThe shininess value of the terrain.
legacySpecularThe specular color of the terrain.
lightmapIndexThe index of the baked lightmap applied to this terrain.
lightmapScaleOffsetThe UV scale & offset used for a baked lightmap.
materialTemplateThe custom material used to render the terrain.
materialTypeThe type of the material used to render the terrain. Could be one of the built-in types or custom. See MaterialType.
realtimeLightmapIndexThe index of the realtime lightmap applied to this terrain.
realtimeLightmapScaleOffsetThe UV scale & offset used for a realtime lightmap.
reflectionProbeUsageHow reflection probes are used for terrain. See ReflectionProbeUsage.
terrainDataThe Terrain Data that stores heightmaps, terrain textures, detail meshes and trees.
treeBillboardDistanceDistance from the camera where trees will be rendered as billboards only.
treeCrossFadeLengthTotal distance delta that trees will use to transition from billboard orientation to mesh orientation.
treeDistanceThe maximum distance at which trees are rendered.
treeMaximumFullLODCountMaximum number of trees rendered at full LOD.

Public Functions

AddTreeInstanceAdds a tree instance to the terrain.
ApplyDelayedHeightmapModificationUpdate the terrain's LOD and vegetation information after making changes with TerrainData.SetHeightsDelayLOD.
FlushFlushes any change done in the terrain so it takes effect.
GetClosestReflectionProbesFills the list with reflection probes whose AABB intersects with terrain's AABB. Their weights are also provided. Weight shows how much influence the probe has on the terrain, and is used when the blending between multiple reflection probes occurs.
GetPositionGet the position of the terrain.
SampleHeightSamples the height at the given position defined in world space, relative to the terrain space.
SetNeighborsLets you setup the connection between neighboring Terrains.

Static Functions

CreateTerrainGameObjectCreates a Terrain including collider from TerrainData.

Inherited members

Variables

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledHas the Behaviour had enabled called.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject (null if there is none attached).
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.

Public Functions

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagIs this game object tagged with tag ?
GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't.
GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the component of Type type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.

Static Functions

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.