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