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

TerrainPaintTool<T0>

class in UnityEditor.Experimental.TerrainAPI

/

Hereda de:ScriptableSingleton_1

Cambiar al Manual

Descripción

Base class for terrain painting tools.

Derive from this class to implement your own terrain painting tools.

using UnityEngine;
using UnityEditor;
using UnityEngine.Experimental.TerrainAPI;

namespace UnityEditor.Experimental.TerrainAPI { public class MyPaintHeightTool : TerrainPaintTool<MyPaintHeightTool> { Material m_Material = null; Material GetPaintMaterial() { if (m_Material == null) m_Material = new Material(Shader.Find("Hidden/Terrain/PaintHeight")); return m_Material; }

public override string GetName() { return "My Paint Height Tool"; }

public override string GetDesc() { return "Left click to raise.\n\nHold shift and left click to lower."; }

public override void OnSceneGUI(Terrain terrain, IOnSceneGUI editContext) { TerrainPaintUtilityEditor.ShowDefaultPreviewBrush(terrain, editContext.brushTexture, editContext.brushSize); }

public override bool OnPaint(Terrain terrain, IOnPaint editContext) { Material mat = TerrainPaintUtility.GetBuiltinPaintMaterial();

float rotationDegrees = 0.0f; BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.uv, editContext.brushSize, rotationDegrees); PaintContext paintContext = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds());

// apply brush Vector4 brushParams = new Vector4(editContext.brushStrength * 0.01f, 0.0f, 0.0f, 0.0f); mat.SetTexture("_BrushTex", editContext.brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat);

Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, (int)TerrainPaintUtility.BuiltinPaintMaterialPasses.RaiseLowerHeight);

TerrainPaintUtility.EndPaintHeightmap(paintContext, "Terrain Paint - MyPaintHeightTool"); return false; } } }

Funciones Públicas

GetDescRetrieves the description of the custom terrain tool.
GetNameRetrieves the name of the custom terrain tool.
OnDisableCalled when the tool is destroyed.
OnEnableCalled when the tool is created.
OnEnterToolModeCalled when the tool is activated.
OnExitToolModeCalled when the tool becomes inactive.
OnInspectorGUICustom terrain tool OnInspectorGUI callback.
OnPaintCustom terrain tool paint callback.
OnSceneGUICustom terrain tool OnSceneGUI callback.

Miembros heredados

Variables Estáticas

instanceGets the instance of the Singleton. Unity creates the Singleton instance when this property is accessed for the first time. If you use the FilePathAttribute, then Unity loads the data on the first access as well.

Variables

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameEl nombre del objeto.

Funciones Públicas

GetInstanceIDDevuelve el id de la instancia del objeto.
ToStringReturns the name of the object.

Funciones Protegidas

SaveSaves the current state of the ScriptableSingleton.

Funciones Estáticas

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeDevuelve el primer objeto activo cargado de tipo type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClona el objeto original y devuelve el clon.
CreateInstanceCrea una instancia de un objeto scriptable.
GetFilePathGet the file path where this ScriptableSingleton is saved to.

Operadores

bool¿Existe el objeto?
operator !=Compare si dos objetos se refieren a un objeto diferente.
operator ==Compara dos referencias de objeto para ver si se refieren al mismo objeto.

Mensajes

AwakeEsta función se llama cuando el script ScriptableObject empieza.
OnDestroyEsta función se llama cuando el objeto scriptable se destruirá.
OnValidateThis function is called when the script is loaded or a value is changed in the Inspector (Called in the editor only).
ResetSe re-inicia a los valores predeterminados.