Version: 2023.2
언어: 한국어

TerrainPaintTool<T0>

class in UnityEditor.TerrainTools

/

다음으로부터 상속:ScriptableSingleton_1

매뉴얼로 전환

설명

Base class for terrain painting tools.

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

using UnityEngine;
using UnityEditor;
using UnityEngine.TerrainTools;

namespace UnityEditor.TerrainTools { 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 GetDescription() { return "Left click to raise.\n\nHold shift and left click to lower."; }

public override void OnRenderBrushPreview(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)TerrainBuiltinPaintMaterialPasses.RaiseLowerHeight);

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

Public 함수

GetDescriptionRetrieves 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.
OnRenderBrushPreviewUse this method to implement custom tool preview and UI behavior that will only render while the mouse is within the SceneView bounds or while you're actively using this tool.
OnSceneGUICustom terrain tool OnSceneGUI callback.

상속된 멤버

정적 변수

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.

변수

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public 함수

GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

보호되는 함수

SaveSaves the current state of the ScriptableSingleton.

정적 함수

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.
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.
CreateInstanceCreates an instance of a scriptable object.
GetFilePathGet the file path where this ScriptableSingleton is saved to.

연산자

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.

메시지

AwakeThis function is called when the ScriptableObject script is started.
OnDestroyThis function is called when the scriptable object will be destroyed.
OnValidateEditor-only function that Unity calls when the script is loaded or a value changes in the Inspector.
ResetReset to default values.