BeginPaintTexture(Terrain, Rect, TerrainLayer, int, bool)
Helper function to set up a PaintContext for modifying the alphamap of one or more Terrain tiles.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: UnityEngine.TerrainTools
- Assembly: UnityEngine.TerrainModule
public static PaintContext BeginPaintTexture(Terrain terrain, Rect boundsInTerrainSpace, TerrainLayer inputLayer, int extraBorderPixels = 0, bool fillOutsideTerrain = true)
Parameters
Reference Terrain tile.
The region in terrain space to edit.
Selects the alphamap to paint.
Number of extra border pixels required.
Whether to fill empty space outside of Terrain tiles with data from the nearest tile.
Returns
Type | Description |
|---|---|
| PaintContext | PaintContext containing the combined alphamap data for the specified region. |
Remarks
BeginPaintTexture identifies all of the alphamap pixels that are within of the bounds rectangle. The search is performed across adjacent connected Terrain tiles. The pixels are collected into a temporary render texture and stored in _sourceRenderTexture.
extraBorderPixelsAfter calling this function, you may modify the alphamap by writing the new values into _destinationRenderTexture. Then, you may complete the modification by calling TerrainPaintUtility.EndPaintTexture to copy the modified data back to the Terrain tiles. Alteratively, you may cancel the modification by calling TerrainPaintUtility.ReleaseContextResources to release the RenderTexture resources.
Additional Resources: TerrainPaintUtility.EndPaintTexture, PaintContext