Class Utility
Provides utility methods for Terrain.
Namespace: UnityEditor.TerrainTools
Syntax
public static class Utility
Methods
AnimationCurveToRenderTexture(AnimationCurve, ref Texture2D)
Converts data from a UnityEngine.AnimationCurve into a UnityEngine.Texture2D
Declaration
public static Vector2 AnimationCurveToRenderTexture(AnimationCurve curve, ref Texture2D tex)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.AnimationCurve | curve | The UnityEngine.AnimationCurve to convert from. |
UnityEngine.Texture2D | tex | The UnityEngine.Texture2D to convert data into. |
Returns
Type | Description |
---|---|
UnityEngine.Vector2 | Returns the range of the UnityEngine.AnimationCurve. |
CollectTexelValidity(Terrain, Rect, Int32)
Retrieves texel context data used for checking texel validity.
Declaration
public static PaintContext CollectTexelValidity(Terrain terrain, Rect boundsInTerrainSpace, int extraBorderPixels = 0)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Terrain | terrain | |
UnityEngine.Rect | boundsInTerrainSpace | |
Int32 | extraBorderPixels |
Returns
Type | Description |
---|---|
UnityEngine.TerrainTools.PaintContext | Returns the UnityEngine.TerrainTools.PaintContext object used for checking texel validity. |
GenerateAndSetFilterRT(IBrushUIGroup, RenderTexture, RenderTexture, Material)
Sets and Generates the filter UnityEngine.RenderTexture for transformation brushes and bind the texture to the provided Material.
Declaration
public static void GenerateAndSetFilterRT(IBrushUIGroup commonUI, RenderTexture sourceRenderTexture, RenderTexture destinationRenderTexture, Material mat)
Parameters
Type | Name | Description |
---|---|---|
IBrushUIGroup | commonUI | The brush's commonUI group. |
UnityEngine.RenderTexture | sourceRenderTexture | The UnityEngine.RenderTexture designated as the source. |
UnityEngine.RenderTexture | destinationRenderTexture | The UnityEngine.RenderTexture designated as the destination. |
UnityEngine.Material | mat | The UnityEngine.Material to update. |
See Also
GetDefaultPreviewMaterial(Boolean)
Retrieves the default preview UnityEngine.Material for painting on Terrains.
Declaration
public static Material GetDefaultPreviewMaterial(bool filtersPreviewEnabled = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | filtersPreviewEnabled | Whether the filter preview is enabled. |
Returns
Type | Description |
---|---|
UnityEngine.Material | Returns Terrain painting's default preview UnityEngine.Material. |
GetPaintHeightMaterial()
Gets the paint height material to render builtin brush passes.
Declaration
public static Material GetPaintHeightMaterial()
Returns
Type | Description |
---|---|
UnityEngine.Material | Material with the Paint Height shader |
Remarks
This material overrides the Builtin PaintHeight shader with Terrain Tools version of PaintHeight. See UnityEngine.TerrainTools.TerrainBuiltinPaintMaterialPasses for the available passes to choose from. See "/com.unity.terrain-tools/Shaders/PaintHeight.shader" for the override PaintHeight shader.
SetMaterialKeyword(Material, String, Boolean)
Enable or disable the keyword for the provided Material instance
Declaration
public static void SetMaterialKeyword(Material mat, string keyword, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Material | mat | The material to set. |
String | keyword | The keyword to enable and disable. |
Boolean | enabled | Whether to enable or disable the keyword of the material. |
SetupMaterialForPainting(PaintContext, BrushTransform, Material)
Prepares the passed in UnityEngine.Material for painting on Terrains.
Declaration
public static void SetupMaterialForPainting(PaintContext paintContext, BrushTransform brushTransform, Material material)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.TerrainTools.PaintContext | paintContext | The painting context data. |
UnityEngine.TerrainTools.BrushTransform | brushTransform | The brush's transformation data. |
UnityEngine.Material | material | The material being used for painting on Terrains. |
See Also
SetupMaterialForPaintingWithTexelValidityContext(PaintContext, PaintContext, BrushTransform, Material)
Prepares the passed in UnityEngine.Material for painting on Terrains while checking for Texel Validity.
Declaration
public static void SetupMaterialForPaintingWithTexelValidityContext(PaintContext paintContext, PaintContext texelCtx, BrushTransform brushTransform, Material material)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.TerrainTools.PaintContext | paintContext | The painting context data. |
UnityEngine.TerrainTools.PaintContext | texelCtx | The texel context data. |
UnityEngine.TerrainTools.BrushTransform | brushTransform | The brush's transformation data. |
UnityEngine.Material | material | The material being used for painting on Terrains. |