Version: 2021.2
LanguageEnglish
  • C#

Terrain

class in UnityEngine

/

Inherits from:Behaviour

/

Implemented in:UnityEngine.TerrainModule

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

Submission failed

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

Close

Cancel

Description

The Terrain component renders the terrain.

Static Properties

activeTerrainThe active Terrain. This is a convenient function to get to the main Terrain in the Scene.
activeTerrainsThe active terrains in the Scene.
compressedHolesFormatGraphics format of the Terrain holes Texture when it is compressed.
compressedHolesTextureFormatTexture format of the Terrain holes Texture when it is compressed.
heightmapFormatGraphics format of the Terrain heightmap.
heightmapRenderTextureFormatRenderTextureFormat of the terrain heightmap.
holesFormatGraphics format of the Terrain holes Texture when it is not compressed.
holesRenderTextureFormatRender texture format of the Terrain holes Texture.
normalmapFormatGraphics format of the Terrain normal map texture.
normalmapRenderTextureFormatRender texture format of the Terrain normal map texture.
normalmapTextureFormatTexture format of the Terrain normal map texture.

Properties

allowAutoConnectSpecifies if the terrain tile will be automatically connected to adjacent tiles.
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.
bottomNeighborTerrain bottom neighbor.
collectDetailPatchesCollect detail patches from memory.
deringLightProbesForTreesRemoves ringing from probes on trees if enabled.
detailObjectDensityDensity of detail objects.
detailObjectDistanceDetail objects will be displayed up to this distance.
drawHeightmapIndicates whether Unity draws the Terrain geometry itself.
drawInstancedSet to true to enable the terrain instance renderer. The default value is false.
drawTreesAndFoliageSpecify if terrain trees and details should be drawn.
editorRenderFlagsControls what part of the terrain should be rendered.
groupingIDGrouping ID for auto connect.
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.
keepUnusedRenderingResourcesDefines whether Unity frees per-Camera rendering resources for the Terrain when those resources aren't in use after a certain number of frames.
leftNeighborThe Terrain tile to the left, which is in the negative X direction.
lightmapIndexThe index of the baked lightmap applied to this terrain.
lightmapScaleOffsetThe UV scale & offset used for a baked lightmap.
materialTemplateThe custom material Unity uses to render the Terrain.
normalmapTextureReturns the normal map texture computed from sampling the heightmap. It is only used when terrain is rendered using instancing.
patchBoundsMultiplierSet the terrain bounding box scale.
preserveTreePrototypeLayersAllows you to specify how Unity chooses the layer for tree instances.
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.
renderingLayerMaskDetermines which rendering layers the Terrain renderer lives on.
rightNeighborThe Terrain tile to the left, which is in the positive X direction.
shadowCastingModeAllows you to set the shadow casting mode for the terrain.
terrainDataThe Terrain Data that stores heightmaps, terrain textures, detail meshes and trees.
topNeighborTerrain top neighbor.
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.
treeLODBiasMultiplierThe multiplier to the current LOD bias used for rendering LOD trees (i.e. SpeedTree trees).
treeMaximumFullLODCountMaximum number of trees rendered at full LOD.

Public Methods

AddTreeInstanceAdds a tree instance to the terrain.
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.
GetKeepUnusedCameraRenderingResources
GetPositionGet the position of the terrain.
GetSplatMaterialPropertyBlockGet the previously set splat material properties by copying to the dest MaterialPropertyBlock object.
SampleHeightSamples the height at the given position defined in world space, relative to the Terrain space.
SetKeepUnusedCameraRenderingResourcesDefines whether Unity cleans up rendering resources for a given Camera during garbage collection.
SetNeighborsLets you set up the connection between neighboring Terrain tiles. This ensures LOD matches up on neighboring Terrain tiles.
SetSplatMaterialPropertyBlockSet the additional material properties when rendering the terrain heightmap using the splat material.

Static Methods

CreateTerrainGameObjectCreates a Terrain including collider from TerrainData.
GetActiveTerrainsPopulates a List of Terrains with the active Terrains in the Scene.
SetConnectivityDirtyMarks the current connectivity status as invalid.

Inherited Members

Properties

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledReports whether a GameObject and its associated Behaviour is active and enabled.
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.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentReturns the component of type if the GameObject has one attached.
GetComponentInChildrenReturns the Component of type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the Component of 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 using depth first search. Works recursively.
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.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all 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.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961