Class RuleTileEditor
The Editor for a RuleTile.
Inherited Members
Namespace: UnityEditor
Assembly: Unity.2D.Tilemap.Extras.Editor.dll
Syntax
[CustomEditor(typeof(RuleTile), true)]
[CanEditMultipleObjects]
public class RuleTileEditor : Editor
Fields
extendNeighbor
Whether the RuleTile can extend its neighbors beyond directly adjacent ones
Declaration
public bool extendNeighbor
Field Value
| Type | Description |
|---|---|
| bool |
k_DefaultElementHeight
Default height for a Rule Element
Declaration
public const float k_DefaultElementHeight = 48
Field Value
| Type | Description |
|---|---|
| float |
k_LabelWidth
Width for labels
Declaration
public const float k_LabelWidth = 80
Field Value
| Type | Description |
|---|---|
| float |
k_PaddingBetweenRules
Padding between Rule Elements
Declaration
public const float k_PaddingBetweenRules = 8
Field Value
| Type | Description |
|---|---|
| float |
k_SingleLineHeight
Single line height
Declaration
public const float k_SingleLineHeight = 18
Field Value
| Type | Description |
|---|---|
| float |
m_PreviewGrid
Grid for rendering previews
Declaration
public Grid m_PreviewGrid
Field Value
| Type | Description |
|---|---|
| Grid |
m_PreviewTilemapRenderers
List of TilemapRenderers for rendering previews
Declaration
public List<TilemapRenderer> m_PreviewTilemapRenderers
Field Value
| Type | Description |
|---|---|
| List<TilemapRenderer> |
m_PreviewTilemaps
List of Tilemaps for rendering previews
Declaration
public List<Tilemap> m_PreviewTilemaps
Field Value
| Type | Description |
|---|---|
| List<Tilemap> |
m_PreviewUtility
Preview Utility for rendering previews
Declaration
public PreviewRenderUtility m_PreviewUtility
Field Value
| Type | Description |
|---|---|
| PreviewRenderUtility |
Properties
arrows
Array of arrow textures used for marking positions for Rule matches
Declaration
public static Texture2D[] arrows { get; }
Property Value
| Type | Description |
|---|---|
| Texture2D[] |
autoTransforms
Arrays of textures used for marking transform Rule matches
Declaration
public static Texture2D[] autoTransforms { get; }
Property Value
| Type | Description |
|---|---|
| Texture2D[] |
tile
The RuleTile being edited
Declaration
public RuleTile tile { get; }
Property Value
| Type | Description |
|---|---|
| RuleTile |
Methods
Base64ToTexture(string)
Converts a Base64 string to a Texture2D
Declaration
public static Texture2D Base64ToTexture(string base64)
Parameters
| Type | Name | Description |
|---|---|---|
| string | base64 | Base64 string containing image data |
Returns
| Type | Description |
|---|---|
| Texture2D | Texture2D containing an image from the given Base64 string |
ContainsMousePosition(Rect)
Determines the current mouse position is within the given Rect.
Declaration
public virtual bool ContainsMousePosition(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to test mouse position for. |
Returns
| Type | Description |
|---|---|
| bool | True if the current mouse position is within the given Rect. False otherwise. |
CopyAllRules(MenuCommand)
Copies all Rules from a RuleTile to the clipboard
Declaration
[MenuItem("CONTEXT/RuleTile/Copy All Rules")]
public static void CopyAllRules(MenuCommand item)
Parameters
| Type | Name | Description |
|---|---|---|
| MenuCommand | item | MenuCommand storing the RuleTile to copy from |
CreatePreview()
Creates a Preview for the RuleTile.
Declaration
protected virtual void CreatePreview()
CreateRuleTileTemplate(MenuCommand)
Create a RuleTile template from this RuleTile
Declaration
[MenuItem("CONTEXT/RuleTile/Create RuleTile Template")]
public static void CreateRuleTileTemplate(MenuCommand item)
Parameters
| Type | Name | Description |
|---|---|---|
| MenuCommand | item | MenuCommand for creating RuleTile template |
DestroyPreview()
Handles cleanup for the Preview GUI
Declaration
protected virtual void DestroyPreview()
DrawCustomFields(bool)
Draw editor fields for custom properties for the RuleTile
Declaration
public void DrawCustomFields(bool isOverrideInstance)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isOverrideInstance | Whether override fields are drawn |
FindAffectedOverrideTiles(RuleTile)
Gets all RuleOverrideTiles which override the given RuleTile
Declaration
public static List<RuleOverrideTile> FindAffectedOverrideTiles(RuleTile target)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleTile | target | RuleTile which has been updated |
Returns
| Type | Description |
|---|---|
| List<RuleOverrideTile> | A list of RuleOverrideTiles which override the given RuleTile |
GetArrowIndex(Vector3Int)
Gets the index for a Rule with the RuleTile to display an arrow.
Declaration
public virtual int GetArrowIndex(Vector3Int position)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | The relative position of the arrow from the center. |
Returns
| Type | Description |
|---|---|
| int | Returns the index for a Rule with the RuleTile to display an arrow. |
GetElementHeight(TilingRule)
Gets the GUI element height for a TilingRule
Declaration
public float GetElementHeight(RuleTile.TilingRule rule)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleTile.TilingRule | rule | Rule to get height for |
Returns
| Type | Description |
|---|---|
| float | GUI element height for a TilingRule |
GetElementHeight(TilingRuleOutput)
Gets the GUI element height for a TilingRuleOutput
Declaration
public float GetElementHeight(RuleTile.TilingRuleOutput rule)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleTile.TilingRuleOutput | rule | Rule to get height for |
Returns
| Type | Description |
|---|---|
| float | GUI element height for a TilingRuleOutput |
GetMatrixSize(BoundsInt)
Gets the GUI matrix size for a Rule of a RuleTile
Declaration
public virtual Vector2 GetMatrixSize(BoundsInt bounds)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundsInt | bounds | Cell bounds of the Rule. |
Returns
| Type | Description |
|---|---|
| Vector2 | Returns the GUI matrix size for a Rule of a RuleTile. |
GetMouseChange()
Gets the offset change for a mouse click input
Declaration
public static int GetMouseChange()
Returns
| Type | Description |
|---|---|
| int | The offset change for a mouse click input |
GetRuleGUIBounds(BoundsInt, TilingRule)
Get the GUI bounds for a Rule.
Declaration
public virtual BoundsInt GetRuleGUIBounds(BoundsInt bounds, RuleTile.TilingRule rule)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundsInt | bounds | Cell bounds of the Rule. |
| RuleTile.TilingRule | rule | Rule to get GUI bounds for. |
Returns
| Type | Description |
|---|---|
| BoundsInt | The GUI bounds for a rule. |
HasPreviewGUI()
Whether the RuleTile has a preview GUI
Declaration
public override bool HasPreviewGUI()
Returns
| Type | Description |
|---|---|
| bool | True |
Overrides
ListUpdated(ReorderableList)
Callback when the Rule list is updated
Declaration
public void ListUpdated(ReorderableList list)
Parameters
| Type | Name | Description |
|---|---|---|
| ReorderableList | list | Reorderable list for Rules |
OnDisable()
OnDisable for the RuleTileEditor
Declaration
public virtual void OnDisable()
OnDrawElement(Rect, int, bool, bool)
Draws the Rule element for the Rule list
Declaration
protected virtual void OnDrawElement(Rect rect, int index, bool isactive, bool isfocused)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw the Rule Element in |
| int | index | Index of the Rule Element to draw |
| bool | isactive | Whether the Rule Element is active |
| bool | isfocused | Whether the Rule Element is focused |
OnDrawHeader(Rect)
Draws the header for the Rule list
Declaration
public void OnDrawHeader(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | GUI Rect to draw the header at |
OnEnable()
OnEnable for the RuleTileEditor
Declaration
public virtual void OnEnable()
OnInspectorGUI()
Draws the Inspector GUI for the RuleTileEditor
Declaration
public override void OnInspectorGUI()
Overrides
OnPreviewGUI(Rect, GUIStyle)
Draws the preview GUI for the RuleTile
Declaration
public override void OnPreviewGUI(Rect rect, GUIStyle background)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw the preview GUI |
| GUIStyle | background | The GUIStyle of the background for the preview |
Overrides
PasteRules(MenuCommand)
Pastes all Rules from the clipboard to a RuleTile
Declaration
[MenuItem("CONTEXT/RuleTile/Paste Rules")]
public static void PasteRules(MenuCommand item)
Parameters
| Type | Name | Description |
|---|---|---|
| MenuCommand | item | MenuCommand storing the RuleTile to paste to |
RenderStaticPreview(string, Object[], int, int)
Renders a static preview Texture2D for a RuleTile asset
Declaration
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| string | assetPath | Asset path of the RuleTile |
| Object[] | subAssets | Arrays of assets from the given Asset path |
| int | width | Width of the static preview |
| int | height | Height of the static preview |
Returns
| Type | Description |
|---|---|
| Texture2D | Texture2D containing static preview for the RuleTile asset |
Overrides
RuleInspectorOnGUI(Rect, TilingRuleOutput)
Draws an Inspector for the Rule
Declaration
public void RuleInspectorOnGUI(Rect rect, RuleTile.TilingRuleOutput tilingRule)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw Inspector in |
| RuleTile.TilingRuleOutput | tilingRule | Rule to draw Inspector for |
RuleMatrixIconOnGUI(TilingRule, Dictionary<Vector3Int, int>, Vector3Int, Rect)
Draws a Rule Matrix Icon for the given matching Rule for a RuleTile with the given position
Declaration
public void RuleMatrixIconOnGUI(RuleTile.TilingRule tilingRule, Dictionary<Vector3Int, int> neighbors, Vector3Int position, Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleTile.TilingRule | tilingRule | Tile to draw rule for. |
| Dictionary<Vector3Int, int> | neighbors | A dictionary of neighbors |
| Vector3Int | position | The relative position of the neighbor matching Rule |
| Rect | rect | GUI Rect to draw icon at |
RuleMatrixOnGUI(RuleTile, Rect, BoundsInt, TilingRule)
Draws a Rule Matrix for the given Rule for a RuleTile.
Declaration
public virtual void RuleMatrixOnGUI(RuleTile tile, Rect rect, BoundsInt bounds, RuleTile.TilingRule tilingRule)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleTile | tile | Tile to draw rule for. |
| Rect | rect | GUI Rect to draw rule at. |
| BoundsInt | bounds | Cell bounds of the Rule. |
| RuleTile.TilingRule | tilingRule | Rule to draw Rule Matrix for. |
RuleNeighborUpdate(Rect, TilingRule, Dictionary<Vector3Int, int>, Vector3Int)
Handles a neighbor matching Rule update from user mouse input
Declaration
public void RuleNeighborUpdate(Rect rect, RuleTile.TilingRule tilingRule, Dictionary<Vector3Int, int> neighbors, Vector3Int position)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect containing neighbor matching Rule GUI |
| RuleTile.TilingRule | tilingRule | Tiling Rule to update neighbor matching rule |
| Dictionary<Vector3Int, int> | neighbors | A dictionary of neighbors |
| Vector3Int | position | The relative position of the neighbor matching Rule |
RuleOnGUI(Rect, Vector3Int, int)
Draws a neighbor matching rule
Declaration
public virtual void RuleOnGUI(Rect rect, Vector3Int position, int neighbor)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw on |
| Vector3Int | position | The relative position of the arrow from the center |
| int | neighbor | The index to the neighbor matching criteria |
RuleTooltipOnGUI(Rect, int)
Draws a tooltip for the neighbor matching rule
Declaration
public void RuleTooltipOnGUI(Rect rect, int neighbor)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw on |
| int | neighbor | The index to the neighbor matching criteria |
RuleTransformOnGUI(Rect, Transform)
Draws a transform matching rule
Declaration
public virtual void RuleTransformOnGUI(Rect rect, RuleTile.TilingRuleOutput.Transform ruleTransform)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw on |
| RuleTile.TilingRuleOutput.Transform | ruleTransform | The transform matching criteria |
RuleTransformUpdate(Rect, TilingRule)
Handles a transform matching Rule update from user mouse input
Declaration
public void RuleTransformUpdate(Rect rect, RuleTile.TilingRule tilingRule)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect containing transform matching Rule GUI |
| RuleTile.TilingRule | tilingRule | Tiling Rule to update transform matching rule |
SaveTile()
Saves any changes to the RuleTile
Declaration
public void SaveTile()
SpriteOnGUI(Rect, TilingRuleOutput)
Draws a Sprite field for the Rule
Declaration
public virtual void SpriteOnGUI(Rect rect, RuleTile.TilingRuleOutput tilingRule)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect to draw Sprite Inspector in |
| RuleTile.TilingRuleOutput | tilingRule | Rule to draw Sprite Inspector for |
UpdateAffectedOverrideTiles(RuleTile)
Updates all RuleOverrideTiles which override the given RUleTile
Declaration
public static void UpdateAffectedOverrideTiles(RuleTile target)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleTile | target | RuleTile which has been updated |