docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class BaseBrushVariator

    Represents an base terrain tools variator class.

    Inheritance
    object
    BaseBrushVariator
    Implements
    IBrushController
    IBrushTerrainCache
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.TerrainTools
    Assembly: Unity.TerrainTools.Editor.dll
    Syntax
    public abstract class BaseBrushVariator : IBrushController, IBrushTerrainCache

    Constructors

    BaseBrushVariator(string, IBrushEventHandler, IBrushTerrainCache)

    Initializes and returns an instance of BaseBrushVariator.

    Declaration
    protected BaseBrushVariator(string toolName, IBrushEventHandler eventHandler, IBrushTerrainCache terrainCache)
    Parameters
    Type Name Description
    string toolName

    The tool's name which the variator is used with.

    IBrushEventHandler eventHandler

    The brush event handler.

    IBrushTerrainCache terrainCache

    The cache reference of the terrain.

    Properties

    canUpdateTerrainUnderCursor

    Checks if the cursor is currently locked and can not be updated.

    Declaration
    public bool canUpdateTerrainUnderCursor { get; }
    Property Value
    Type Description
    bool

    isInUse

    Checks if the brush is in use.

    Declaration
    public virtual bool isInUse { get; }
    Property Value
    Type Description
    bool

    isRaycastHitUnderCursorValid

    Gets and sets the value associated to whether there is a raycast hit detecting a terrain under the cursor.

    Declaration
    public bool isRaycastHitUnderCursorValid { get; }
    Property Value
    Type Description
    bool

    raycastHitUnderCursor

    Gets and sets the raycast hit that was under the cursor's position.

    Declaration
    public RaycastHit raycastHitUnderCursor { get; }
    Property Value
    Type Description
    RaycastHit

    s_SceneLabelStyle

    Gets the the GUIStyle of the scene's label.

    Declaration
    protected static GUIStyle s_SceneLabelStyle { get; }
    Property Value
    Type Description
    GUIStyle

    terrainUnderCursor

    Gets and sets the terrain in focus.

    Declaration
    public Terrain terrainUnderCursor { get; }
    Property Value
    Type Description
    Terrain

    Methods

    AppendBrushInfo(Terrain, IOnSceneGUI, StringBuilder)

    Adds basic information to the selected brush.

    Declaration
    public virtual void AppendBrushInfo(Terrain terrain, IOnSceneGUI editContext, StringBuilder builder)
    Parameters
    Type Name Description
    Terrain terrain

    The Terrain in focus.

    IOnSceneGUI editContext

    The IOnSceneGUI to reference.

    StringBuilder builder

    The StringBuilder containing the brush information.

    CalculateMouseDelta(Event, float)

    Gets the mouses delta from the mouse event.

    Declaration
    protected static Vector2 CalculateMouseDelta(Event mouseEvent, float scale = 1)
    Parameters
    Type Name Description
    Event mouseEvent

    The current mouse event.

    float scale

    The scale to multiply the delta by.

    Returns
    Type Description
    Vector2

    Returns the mouses delta.

    See Also
    CalculateMouseDeltaFromInitialPosition(Event, float)

    CalculateMouseDeltaFromInitialPosition(Event, float)

    Calculates the difference between the mouses initial and current position.

    Declaration
    protected Vector2 CalculateMouseDeltaFromInitialPosition(Event mouseEvent, float scale = 1)
    Parameters
    Type Name Description
    Event mouseEvent

    The current mouse event.

    float scale

    The scale to multiply the delta by.

    Returns
    Type Description
    Vector2

    Returns the difference between the initial and current position of the mouse.

    See Also
    CalculateMouseDelta(Event, float)

    GetEditorPrefs(string, bool)

    Gets the editor preferences for boolean values.

    Declaration
    protected bool GetEditorPrefs(string name, bool defaultValue)
    Parameters
    Type Name Description
    string name

    The name of the preference.

    bool defaultValue

    The default value of the preference.

    Returns
    Type Description
    bool

    Returns the editor preference value corresponding to the name.

    See Also
    SetEditorPrefs(string, bool)

    GetEditorPrefs(string, float)

    Gets the editor preferences for float values.

    Declaration
    protected float GetEditorPrefs(string name, float defaultValue)
    Parameters
    Type Name Description
    string name

    The name of the preference.

    float defaultValue

    The default value of the preference.

    Returns
    Type Description
    float

    Returns the editor preference value corresponding to the name.

    See Also
    SetEditorPrefs(string, float)

    LockTerrainUnderCursor(bool)

    Handles the locking of the terrain cursor in it's current position.

    Declaration
    public void LockTerrainUnderCursor(bool cursorVisible)
    Parameters
    Type Name Description
    bool cursorVisible

    Whether the cursor is visible within the scene. When the value is true the cursor is visible.

    Remarks

    This method is commonly used when utilizing shortcuts.

    See Also
    UnlockTerrainUnderCursor()

    OnBeginModifier()

    Called when the Variator is initially modified.

    Declaration
    protected virtual bool OnBeginModifier()
    Returns
    Type Description
    bool

    Returns true when the modification is successful. Otherwise, returns false.

    Remarks

    This method is to be overriden when creating custom variators.

    OnEndModifier()

    Called when the Variator's modification has finished.

    Declaration
    protected virtual bool OnEndModifier()
    Returns
    Type Description
    bool

    Returns true when the modification is successful. Otherwise, returns false.

    Remarks

    This method is to be overriden when creating custom variators.

    OnEnterToolMode(BrushShortcutHandler<BrushShortcutType>)

    Defines data when the brush is selected.

    Declaration
    public virtual void OnEnterToolMode(BrushShortcutHandler<BrushShortcutType> shortcutHandler)
    Parameters
    Type Name Description
    BrushShortcutHandler<BrushShortcutType> shortcutHandler

    The shortcut handler to subscribe brush shortcuts.

    See Also
    OnExitToolMode(BrushShortcutHandler<BrushShortcutType>)
    AddActions(TKey, Action, Action)

    OnExitToolMode(BrushShortcutHandler<BrushShortcutType>)

    Defines data when the brush is deselected.

    Declaration
    public virtual void OnExitToolMode(BrushShortcutHandler<BrushShortcutType> shortcutHandler)
    Parameters
    Type Name Description
    BrushShortcutHandler<BrushShortcutType> shortcutHandler

    The shortcut handler to unsubscribe brush shortcuts.

    See Also
    OnEnterToolMode(BrushShortcutHandler<BrushShortcutType>)
    AddActions(TKey, Action, Action)

    OnInspectorGUI(Terrain, IOnInspectorGUI)

    Renders the brush's GUI within the inspector view.

    Declaration
    public virtual void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
    Parameters
    Type Name Description
    Terrain terrain

    The terrain in focus.

    IOnInspectorGUI editContext

    The editcontext used to show the brush GUI.

    OnModifierUsingMouseMove(Event, Terrain, IOnSceneGUI)

    Called when a mouse drag is used when modifying a Variator.

    Declaration
    protected virtual bool OnModifierUsingMouseMove(Event mouseEvent, Terrain terrain, IOnSceneGUI editContext)
    Parameters
    Type Name Description
    Event mouseEvent

    The current mouse event.

    Terrain terrain

    The terrain in focus.

    IOnSceneGUI editContext

    The editcontext to reference.

    Returns
    Type Description
    bool

    Returns true when the modification is successful. Otherwise, returns false.

    Remarks

    This method is to be overriden when creating custom variators.

    OnModifierUsingMouseWheel(Event, Terrain, IOnSceneGUI)

    Called when a mouse wheel is used when modifying a Variator.

    Declaration
    protected virtual bool OnModifierUsingMouseWheel(Event mouseEvent, Terrain terrain, IOnSceneGUI editContext)
    Parameters
    Type Name Description
    Event mouseEvent

    The current mouse event.

    Terrain terrain

    The terrain in focus.

    IOnSceneGUI editContext

    The editcontext to reference.

    Returns
    Type Description
    bool

    Returns true when the modification is successful. Otherwise, returns false.

    Remarks

    This method is to be overriden when creating custom variators.

    OnPaint(Terrain, IOnPaint)

    Triggers events when painting on a terrain.

    Declaration
    public virtual bool OnPaint(Terrain terrain, IOnPaint editContext)
    Parameters
    Type Name Description
    Terrain terrain

    The terrain in focus.

    IOnPaint editContext

    The editcontext to reference.

    Returns
    Type Description
    bool

    Returns true if the paint opertation is succesful. Otherise, returns false.

    OnSceneGUI(Event, int, Terrain, IOnSceneGUI)

    Triggers events to render objects and displays within Scene view.

    Declaration
    public virtual void OnSceneGUI(Event currentEvent, int controlId, Terrain terrain, IOnSceneGUI editContext)
    Parameters
    Type Name Description
    Event currentEvent

    The event to check whether the mouse is in use.

    int controlId

    The control ID of the GUI.

    Terrain terrain

    The terrain in focus.

    IOnSceneGUI editContext

    The editcontext to reference

    RequestRepaint()

    Sets the repaint request to true.

    Declaration
    protected void RequestRepaint()

    SetEditorPrefs(string, bool)

    Sets the editor preferences for boolean values.

    Declaration
    protected void SetEditorPrefs(string name, bool currentValue)
    Parameters
    Type Name Description
    string name

    The name of the preference.

    bool currentValue

    The prefence value to set.

    See Also
    GetEditorPrefs(string, bool)

    SetEditorPrefs(string, float)

    Sets the editor preferences for float values.

    Declaration
    protected void SetEditorPrefs(string name, float currentValue)
    Parameters
    Type Name Description
    string name

    The name of the preference.

    float currentValue

    The prefence value to set.

    See Also
    GetEditorPrefs(string, float)

    UnlockTerrainUnderCursor()

    Handles unlocking of the terrain cursor.

    Declaration
    public void UnlockTerrainUnderCursor()
    See Also
    LockTerrainUnderCursor(bool)

    Implements

    IBrushController
    IBrushTerrainCache
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)