Version: 2021.1
Experimental: this API is experimental and might be changed or removed in the future.

TerrainPaintUtility.BeginPaintHeightmap

切换到手册
public static Experimental.TerrainAPI.PaintContext BeginPaintHeightmap (Terrain terrain, Rect boundsInTerrainSpace, int extraBorderPixels);

参数

terrain 参考地形区块。
boundsInTerrainSpace 要编辑的地形空间中的区域。
extraBorderPixels 所需的额外边框像素数量。

返回

PaintContext 包含指定区域的组合高度贴图数据的 PaintContext。

描述

Helper 函数,用于设置 PaintContext 来修改一个或多个地形区块的高度贴图。

BeginPaintHeightmap 标识位于边界矩形的 extraBorderPixels 中的所有高度贴图像素。 将在相邻的连接地形区块中搜索。 像素被收集到临时渲染纹理中并存储在 PaintContext.sourceRenderTexture 中。

调用此函数后,可以通过将新值写入到 PaintContext.destinationRenderTexture 中修改高度贴图。 然后,可以通过调用 TerrainPaintUtility.EndPaintHeightmap 将修改后的数据复制回地形区块,从而完成修改。 或者,也可以调用 TerrainPaintUtility.ReleaseContextResources 来释放 RenderTexture 资源,从而取消修改。

另请参阅:TerrainPaintUtility.EndPaintHeightmapPaintContext