Class BaseBrushVariator
Represents an base terrain tools variator class.
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
isInUse
Checks if the brush is in use.
Declaration
public virtual bool isInUse { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
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
raycastHitUnderCursor
Gets and sets the raycast hit that was under the cursor's position.
Declaration
public RaycastHit raycastHitUnderCursor { get; }
Property Value
Type | Description |
---|---|
UnityEngine.RaycastHit |
Implements
s_SceneLabelStyle
Gets the the GUIStyle of the scene's label.
Declaration
protected static GUIStyle s_SceneLabelStyle { get; }
Property Value
Type | Description |
---|---|
UnityEngine.GUIStyle |
terrainUnderCursor
Gets and sets the terrain in focus.
Declaration
public Terrain terrainUnderCursor { get; }
Property Value
Type | Description |
---|---|
UnityEngine.Terrain |
Implements
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 |
---|---|---|
UnityEngine.Terrain | terrain | The Terrain in focus. |
UnityEditor.TerrainTools.IOnSceneGUI | editContext | The IOnSceneGUI to reference. |
StringBuilder | builder | The StringBuilder containing the brush information. |
Implements
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 |
---|---|---|
UnityEngine.Event | mouseEvent | The current mouse event. |
Single | scale | The scale to multiply the delta by. |
Returns
Type | Description |
---|---|
UnityEngine.Vector2 | Returns the mouses delta. |
See Also
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 |
---|---|---|
UnityEngine.Event | mouseEvent | The current mouse event. |
Single | scale | The scale to multiply the delta by. |
Returns
Type | Description |
---|---|
UnityEngine.Vector2 | Returns the difference between the initial and current position of the mouse. |
See Also
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
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
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 |
Implements
Remarks
This method is commonly used when utilizing shortcuts.
See Also
OnBeginModifier()
Called when the Variator is initially modified.
Declaration
protected virtual bool OnBeginModifier()
Returns
Type | Description |
---|---|
Boolean | Returns |
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 |
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
See Also
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
See Also
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 |
---|---|---|
UnityEngine.Terrain | terrain | The terrain in focus. |
UnityEditor.TerrainTools.IOnInspectorGUI | editContext | The editcontext used to show the brush GUI. |
Implements
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 |
---|---|---|
UnityEngine.Event | mouseEvent | The current mouse event. |
UnityEngine.Terrain | terrain | The terrain in focus. |
UnityEditor.TerrainTools.IOnSceneGUI | editContext | The editcontext to reference. |
Returns
Type | Description |
---|---|
Boolean | Returns |
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 |
---|---|---|
UnityEngine.Event | mouseEvent | The current mouse event. |
UnityEngine.Terrain | terrain | The terrain in focus. |
UnityEditor.TerrainTools.IOnSceneGUI | editContext | The editcontext to reference. |
Returns
Type | Description |
---|---|
Boolean | Returns |
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 |
---|---|---|
UnityEngine.Terrain | terrain | The terrain in focus. |
UnityEditor.TerrainTools.IOnPaint | editContext | The editcontext to reference. |
Returns
Type | Description |
---|---|
Boolean | Returns |
Implements
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 |
---|---|---|
UnityEngine.Event | currentEvent | The event to check whether the mouse is in use. |
Int32 | controlId | The control ID of the GUI. |
UnityEngine.Terrain | terrain | The terrain in focus. |
UnityEditor.TerrainTools.IOnSceneGUI | editContext | The editcontext to reference |
Implements
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
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
UnlockTerrainUnderCursor()
Handles unlocking of the terrain cursor.
Declaration
public void UnlockTerrainUnderCursor()