Version: 2017.3 (switch to 2017.4)
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

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 convenience function to get to the main terrain in the scene.
activeTerrainsThe active terrains in the scene.

Properties

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.
editorRenderFlagsControls what part of the terrain should be rendered.
freeUnusedRenderingResourcesWhether some per-camera rendering resources for the terrain should be freed after not being used for some frames.
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.
patchBoundsMultiplierSet the terrain bounding box scale.
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.
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.
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.
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.
SetNeighborsLets you setup the connection between neighboring Terrains.
SetSplatMaterialPropertyBlockSet the additional material properties when rendering the terrain heightmap using the splat material.

Static Methods

CreateTerrainGameObjectCreates a Terrain including collider from TerrainData.

Inherited Members

Properties

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.
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.
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 GameObject.

Static Methods

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.
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答