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

TerrainPaintTool<T0>

class in UnityEditor.Experimental.TerrainAPI

/

継承:ScriptableObject

マニュアルに切り替える

説明

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; } } }

Public 関数

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.
OnInspectorGUICustom terrain tool OnInspectorGUI callback.
OnPaintCustom terrain tool paint callback.
OnSceneGUICustom terrain tool OnSceneGUI callback.

継承メンバー

変数

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名

Public 関数

GetInstanceIDオブジェクトのインスタンス ID を返します
ToStringReturns the name of the object.

Static 関数

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.
FindObjectOfTypeタイプ type から最初に見つけたアクティブのオブジェクトを返します
FindObjectsOfTypeタイプから見つけたすべてのアクティブのオブジェクト配列を返します
Instantiateoriginal のオブジェクトをクローンします
CreateInstanceScriptableObject のインスタンスを作成します。

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。

メッセージ

Awake ScriptableObject スクリプトを開始するとき、この関数は呼び出されます。
OnDestroyScriptableObject が破棄されるとき、この関数は呼び出されます。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961