Class Filter
Provides methods for implementing Filters that operate on Textures. Used as elements in a FilterStack but can also be used by themselves. Inherit from this class and override functions to create your own Filter.
Inherited Members
Namespace: UnityEditor.TerrainTools
Assembly: Unity.TerrainTools.Editor.dll
Syntax
[Serializable]
public class Filter : ScriptableObject
Fields
enabled
Flag that is used to determine whether or not the Filter is enabled and should be evaluated when part of a FilterStack. If it is not enabled, it is skipped during FilterStack evaluation
Declaration
[SerializeField]
public bool enabled
Field Value
Type | Description |
---|---|
bool |
Methods
DrawGUI(Rect, FilterContext)
Draws the GUI for the Filter.
Declaration
public void DrawGUI(Rect rect, FilterContext filterContext)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The Rect where the GUI should be drawn. |
FilterContext | filterContext | The FilterContext related to the current evaluation. Use this to show different information in the Filter GUI. |
Eval(FilterContext, RenderTexture, RenderTexture)
Evaluates the Filter.
Declaration
public void Eval(FilterContext filterContext, RenderTexture source, RenderTexture dest)
Parameters
Type | Name | Description |
---|---|---|
FilterContext | filterContext | The FilterContext related to the current evaluation. |
RenderTexture | source | The source RenderTexture on which the Filter operates. |
RenderTexture | dest | The destination RenderTexture to which the Filter blits the results of the Filter evaluation. |
Remarks
This method calls ValidateFilter(FilterContext, out string) and checks if it returns false performing a default blit instead of calling OnEval.
GetDisplayName()
Gets the display name for the Filter. This is used when drawing the Filter's user interface.
Declaration
public virtual string GetDisplayName()
Returns
Type | Description |
---|---|
string | Returns the display name of the Filter. |
GetElementHeight()
Gets the height of the Filter element when drawn as part of a FilterStack GUI.
Declaration
public virtual float GetElementHeight()
Returns
Type | Description |
---|---|
float | The height of the Filter in the FilterStack GUI. |
GetObjectsToSerialize()
Gets a list of Unity Objects to serialize along with the Filter object.
Declaration
public virtual List<Object> GetObjectsToSerialize()
Returns
Type | Description |
---|---|
List<Object> | List of Unity Objects to serialize. |
GetToolTip()
Gets the tooltip for the Filter.
Declaration
public virtual string GetToolTip()
Returns
Type | Description |
---|---|
string | Returns the tooltip of the Filter. |
OnDisable()
Sets data when the Filter is disabled.
Declaration
public virtual void OnDisable()
OnDrawGUI(Rect, FilterContext)
Draws the GUI for the Filter.
Declaration
protected virtual void OnDrawGUI(Rect rect, FilterContext filterContext)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect | The Rect where the GUI should be drawn. |
FilterContext | filterContext | The FilterContext related to the current evaluation. Use this to show different information in the Filter GUI. |
OnEnable()
Sets data when the Filter is first created.
Declaration
public virtual void OnEnable()
OnEval(FilterContext, RenderTexture, RenderTexture)
Evaluates the Filter. Override this function for custom Filter logic.
Declaration
protected virtual void OnEval(FilterContext filterContext, RenderTexture source, RenderTexture dest)
Parameters
Type | Name | Description |
---|---|---|
FilterContext | filterContext | The FilterContext related to the current evaluation. |
RenderTexture | source | The source RenderTexture on which the Filter operates. |
RenderTexture | dest | The destination RenderTexture to which the Filter blits the results of the Filter operation. |
OnSceneGUI(SceneView, FilterContext)
Handles SceneView related logic or rendering.
Declaration
protected virtual void OnSceneGUI(SceneView sceneView, FilterContext filterContext)
Parameters
Type | Name | Description |
---|---|---|
SceneView | sceneView | The SceneView in focus. |
FilterContext | filterContext | The FilterContext related to the current evaluation. |
SceneGUI(SceneView, FilterContext)
Handles SceneView related logic or rendering.
Declaration
public void SceneGUI(SceneView sceneView, FilterContext filterContext)
Parameters
Type | Name | Description |
---|---|---|
SceneView | sceneView | The SceneView in focus. |
FilterContext | filterContext | The FilterContext related to the current evaluation. |
ValidateFilter(FilterContext, out string)
Sets up necessary data needed before the Filter is evaluated.
Declaration
public virtual bool ValidateFilter(FilterContext filterContext, out string message)
Parameters
Type | Name | Description |
---|---|---|
FilterContext | filterContext | The FilterContext related to the current evaluation |
string | message | The message to display from validation results. |
Returns
Type | Description |
---|---|
bool | Whether or not the Filter is supported and should be evaluated. True = supported and is okay to evaluate. False = the Filter is not supported with the current hardware and should be skipped. |
Remarks
While the data is being set the system is informed whether or not the Filter is supported based on current hardware, the data provided by the provided FilterContext, etc. This is completed by returning True or False. This method is called before OnEval.