Version: 2021.2

TerrainData

class in UnityEngine

/

继承自:Object

切换到手册

描述

TerrainData 类负责存储高度贴图、细节网格位置、树实例和地形纹理 Alpha 贴图。

Terrain 组件链接到地形数据并渲染它。

静态变量

AlphamapTextureName地形 Alpha 贴图纹理的名称。
HolesTextureName地形孔洞纹理的名称。

变量

alphamapHeightHeight of the alpha map. (Read only.)
alphamapLayersAlpha 贴图的图层数量。
alphamapResolutionThe size of the alpha map in texels for either the width or the height.
alphamapTextureCount返回 Alpha 贴图纹理的数量。
alphamapTextures地形使用的 Alpha 贴图纹理。供 Terrain Inspector 用于实现撤销操作。
alphamapWidthAlpha 贴图的宽度。
baseMapResolution用于在地形上渲染远处斑块的底图的分辨率。
boundsTerrainData 对象的本地包围盒。
detailHeightThe resolution of the detail data stored in TerrainData.
detailPatchCount沿地形区块边缘的面片数。此属性在经过平方后生成面片网格。
detailPrototypesContains the detail texture/meshes that the Terrain has.
detailResolutionTerrainData 的细节分辨率。
detailResolutionPerPatch每个斑块的细节分辨率。较大的值将减少细节对象使用的批次数。
detailWidthThe resolution of the detail data stored in TerrainData.
enableHolesTextureCompression启用地形孔洞纹理压缩。
heightmapResolutionThe size of the heightmap in texels for either the width or the height.
heightmapScaleReturns a Vector3 where the x and z components are the size of each heightmap sample (i.e. the space between two neighboring heightmap samples), and the y component is the entire Terrain's height range in world space.
heightmapTexture返回高度贴图纹理。
holesResolution返回数据和纹理的地形孔洞分辨率。
holesTexture返回地形孔洞纹理。
size地形的总大小(世界单位)。
terrainLayers检索当前地形使用的地形层。
treeInstanceCount返回树实例的数量。
treeInstances包含当前放置在地形中的树。
treePrototypes可在 Inspector 中使用的树原型的列表。
wavingGrassAmount地形中摇摆的草的数量。
wavingGrassSpeed摇摆草的速度。
wavingGrassStrength地形中摇摆的草的强度。
wavingGrassTint地形具有的摇摆的草的颜色。

公共函数

ComputeDetailInstanceTransformsThis function computes and returns an array of detail object transforms for the specified patch and the specified prototype. You can use this function to retrieve the exact same transform data the Unity engine uses for detail rendering.
CopyActiveRenderTextureToHeightmap将活动 RenderTexture 的指定部分复制到地形高度贴图纹理。
CopyActiveRenderTextureToTexture将活动 RenderTexture 的指定部分复制到地形纹理。
DirtyHeightmapRegion将高度贴图的指定部分标记为“脏”。
DirtyTextureRegion将地形纹理的指定部分标记为“脏”。
GetAlphamaps返回位置 x、y 处给定宽度和高度的 Alpha 贴图。
GetAlphamapTexture返回指定索引处的 Alpha 贴图纹理。
GetClampedDetailPatchesReturns an array of detail patches, which are each identified by X-Z coordinates. Detail objects in the patches are clamped to the maximum count.
GetDetailLayerReturns a 2D array of the detail object density (i.e. the number of detail objects for this layer) in the specific location.
GetHeightGets the world space height of the Terrain at a certain point x,y without adding the Terrain's world position y.
GetHeightsGets an array of heightmap samples.
GetHoles获取地形孔洞样本数组。
GetInterpolatedHeight获取点 (x,y) 处的插值高度。x 和 y 坐标钳制到 [0, 1] 内。
GetInterpolatedHeights使用标准化 x,y 坐标获取地形高度值的数组。
GetInterpolatedNormal获取给定位置处的插值法线。
GetMaximumHeightError返回每个可渲染地形面片的曲面细分最大高度误差值数组。可以修改返回的数组并将其传递给 OverrideMaximumHeightError。
GetPatchMinMaxHeights返回地形中所有可渲染面片的最小/最大高度值数组。可以修改返回的数组,然后将其传递给 OverrideMinMaxPatchHeights。
GetSteepness获取点 (x,y) 处的地形梯度。
GetSupportedLayers返回区域中所有支持的细节层索引的数组。
GetTreeInstance获取指定索引处的树实例。该函数不创建整个树实例数组,因此可当作更快版本的 treeInstances[index] 使用。
IsHole获取 x,y 处的特定点是否为孔洞。
OverrideMaximumHeightError使用用户提供的值重写最大曲面细分高度误差。请注意,重写的值会在地形分辨率更改时重置,而在通过脚本绘制或更改地形高度贴图时保持不变。
OverrideMinMaxPatchHeights重写每个可渲染地形面片的最小和最大面片高度。请注意,重写的值会在地形分辨率更改时重置,而在通过脚本绘制或更改地形高度贴图时保持不变。
RefreshPrototypes重新加载 TerrainData 对象中可用原型(即细节网格资源)的所有值。
SetAlphamaps在给定贴图区域中分配所有泼溅值。
SetBaseMapDirty将地形数据标记为脏以触发地形基础贴图纹理的更新。
SetDetailLayer设置细节层密度贴图。
SetDetailResolution设置细节贴图的分辨率。
SetHeights设置一个高度贴图样本数组。
SetHeightsDelayLOD设置一个高度贴图样本数组。
SetHoles设置地形孔洞样本数组。
SetHolesDelayLOD设置地形孔洞样本数组。
SetTerrainLayersRegisterUndo此函数设置 terrainLayers 属性,此外,将操作注册到编辑器的撤销堆栈。
SetTreeInstance使用新参数在指定索引处设置树实例。但是,无法更改 TreeInstance.prototypeIndex 和 TreeInstance.position。如果更改它们,则该方法会抛出 ArgumentException。
SetTreeInstances设置树实例数组,可以选择将树贴靠到地形高度贴图的表面上。
SyncHeightmap执行按以前的 CopyActiveRenderTextureToHeightmap 和 DirtyHeightmapRegion 调用排队的同步,这可使用于曲面细分的高度数据和 LOD 数据保持最新状态。
SyncTexture执行按以前的 CopyActiveRenderTextureToTexture 和 DirtyTextureRegion 调用排队的同步,这可使地形纹理的 CPU 数据保持最新状态。

继承的成员

变量

hideFlags该对象应该隐藏、随场景一起保存还是由用户修改?
name对象的名称。

公共函数

GetInstanceIDGets the instance ID of the object.
ToString返回对象的名称。

静态函数

Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。

运算符

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。