class in UnityEditor.Experimental.TerrainAPI
/
Hereda de:ScriptableSingleton_1
Cambiar al ManualBase 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; } } }
GetDesc | Retrieves the description of the custom terrain tool. |
GetName | Retrieves the name of the custom terrain tool. |
OnDisable | Called when the tool is destroyed. |
OnEnable | Called when the tool is created. |
OnEnterToolMode | Called when the tool is activated. |
OnExitToolMode | Called when the tool becomes inactive. |
OnInspectorGUI | Custom terrain tool OnInspectorGUI callback. |
OnPaint | Custom terrain tool paint callback. |
OnSceneGUI | Custom terrain tool OnSceneGUI callback. |
instance | Gets 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. |
hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
name | El nombre del objeto. |
GetInstanceID | Devuelve el id de la instancia del objeto. |
ToString | Returns the name of the object. |
Save | Saves the current state of the ScriptableSingleton. |
Destroy | Removes a GameObject, component or asset. |
DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. |
DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. |
FindObjectOfType | Devuelve el primer objeto activo cargado de tipo type. |
FindObjectsOfType | Gets a list of all loaded objects of Type type. |
Instantiate | Clona el objeto original y devuelve el clon. |
CreateInstance | Crea una instancia de un objeto scriptable. |
GetFilePath | Get the file path where this ScriptableSingleton is saved to. |
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. |
Awake | Esta función se llama cuando el script ScriptableObject empieza. |
OnDestroy | Esta función se llama cuando el objeto scriptable se destruirá. |
OnValidate | This function is called when the script is loaded or a value is changed in the Inspector (Called in the editor only). |
Reset | Se re-inicia a los valores predeterminados. |