docs.unity3d.com
    Show / Hide Table of Contents

    Class BaseBrushVariator

    Represents an base terrain tools variator class.

    Inheritance
    Object
    BaseBrushVariator
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEditor.TerrainTools
    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
    Boolean
    Implements
    IBrushTerrainCache.canUpdateTerrainUnderCursor

    isInUse

    Checks if the brush is in use.

    Declaration
    public virtual bool isInUse { get; }
    Property Value
    Type Description
    Boolean
    Implements
    IBrushController.isInUse

    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
    Boolean
    Implements
    IBrushTerrainCache.isRaycastHitUnderCursorValid

    raycastHitUnderCursor

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

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

    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
    Implements
    IBrushTerrainCache.terrainUnderCursor

    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.

    Implements
    IBrushController.AppendBrushInfo(Terrain, IOnSceneGUI, StringBuilder)

    CalculateMouseDelta(Event, Single)

    Gets the mouses delta from the mouse event.

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

    The current mouse event.

    Single scale

    The scale to multiply the delta by.

    Returns
    Type Description
    Vector2

    Returns the mouses delta.

    See Also
    CalculateMouseDeltaFromInitialPosition(Event, Single)

    CalculateMouseDeltaFromInitialPosition(Event, Single)

    Calculates the difference between the mouses initial and current position.

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

    The current mouse event.

    Single 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, Single)

    GetEditorPrefs(String, Boolean)

    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.

    Boolean defaultValue

    The default value of the preference.

    Returns
    Type Description
    Boolean

    Returns the editor preference value corresponding to the name.

    See Also
    SetEditorPrefs(String, Boolean)

    GetEditorPrefs(String, Single)

    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.

    Single defaultValue

    The default value of the preference.

    Returns
    Type Description
    Single

    Returns the editor preference value corresponding to the name.

    See Also
    SetEditorPrefs(String, Single)

    LockTerrainUnderCursor(Boolean)

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

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

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

    Implements
    IBrushTerrainCache.LockTerrainUnderCursor(Boolean)
    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
    Boolean

    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
    Boolean

    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.

    Implements
    IBrushController.OnEnterToolMode(BrushShortcutHandler<BrushShortcutType>)
    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.

    Implements
    IBrushController.OnExitToolMode(BrushShortcutHandler<BrushShortcutType>)
    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.

    Implements
    IBrushController.OnInspectorGUI(Terrain, IOnInspectorGUI)

    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
    Boolean

    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
    Boolean

    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
    Boolean

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

    Implements
    IBrushController.OnPaint(Terrain, IOnPaint)

    OnSceneGUI(Event, Int32, 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.

    Int32 controlId

    The control ID of the GUI.

    Terrain terrain

    The terrain in focus.

    IOnSceneGUI editContext

    The editcontext to reference

    Implements
    IBrushController.OnSceneGUI(Event, Int32, Terrain, IOnSceneGUI)

    RequestRepaint()

    Sets the repaint request to true.

    Declaration
    protected void RequestRepaint()

    SetEditorPrefs(String, Boolean)

    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.

    Boolean currentValue

    The prefence value to set.

    See Also
    GetEditorPrefs(String, Boolean)

    SetEditorPrefs(String, Single)

    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.

    Single currentValue

    The prefence value to set.

    See Also
    GetEditorPrefs(String, Single)

    UnlockTerrainUnderCursor()

    Handles unlocking of the terrain cursor.

    Declaration
    public void UnlockTerrainUnderCursor()
    Implements
    IBrushTerrainCache.UnlockTerrainUnderCursor()
    See Also
    LockTerrainUnderCursor(Boolean)
    Back to top
    Copyright © 2023 Unity Technologies
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on Friday, November 3, 2023