docs.unity3d.com
    Show / Hide Table of Contents

    Class RuleTileEditor

    The Editor for a RuleTile.

    Inheritance
    Object
    Object
    ScriptableObject
    Editor
    RuleTileEditor
    HexagonalRuleTileEditor
    IsometricRuleTileEditor
    Inherited Members
    Editor.CreateEditorWithContext(Object[], Object, Type)
    Editor.CreateEditorWithContext(Object[], Object)
    Editor.CreateCachedEditorWithContext(Object, Object, Type, Editor)
    Editor.CreateCachedEditorWithContext(Object[], Object, Type, Editor)
    Editor.CreateCachedEditor(Object, Type, Editor)
    Editor.CreateCachedEditor(Object[], Type, Editor)
    Editor.CreateEditor(Object)
    Editor.CreateEditor(Object, Type)
    Editor.CreateEditor(Object[])
    Editor.CreateEditor(Object[], Type)
    Editor.DrawPropertiesExcluding(SerializedObject, String[])
    Editor.DrawDefaultInspector()
    Editor.Repaint()
    Editor.CreateInspectorGUI()
    Editor.RequiresConstantRepaint()
    Editor.DrawHeader()
    Editor.OnHeaderGUI()
    Editor.ShouldHideOpenButton()
    Editor.DrawFoldoutInspector(Object, Editor)
    Editor.GetPreviewTitle()
    Editor.OnInteractivePreviewGUI(Rect, GUIStyle)
    Editor.OnPreviewSettings()
    Editor.GetInfoString()
    Editor.DrawPreview(Rect)
    Editor.ReloadPreviewInstances()
    Editor.UseDefaultMargins()
    Editor.Initialize(Object[])
    Editor.MoveNextTarget()
    Editor.ResetTarget()
    Editor.target
    Editor.targets
    Editor.serializedObject
    Editor.finishedDefaultHeaderGUI
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(String)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    UnityEngine.Object.FindObjectsOfType(System.Type, System.Boolean)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    UnityEngine.Object.FindObjectOfType(System.Type, System.Boolean)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEditor
    Syntax
    [CustomEditor(typeof(RuleTile), true)]
    [CanEditMultipleObjects]
    public class RuleTileEditor : Editor, IPreviewable, IToolModeOwner

    Fields

    extendNeighbor

    Whether the RuleTile can extend its neighbors beyond directly adjacent ones

    Declaration
    public bool extendNeighbor
    Field Value
    Type Description
    Boolean

    k_DefaultElementHeight

    Default height for a Rule Element

    Declaration
    public const float k_DefaultElementHeight = 48F
    Field Value
    Type Description
    Single

    k_LabelWidth

    Width for labels

    Declaration
    public const float k_LabelWidth = 80F
    Field Value
    Type Description
    Single

    k_PaddingBetweenRules

    Padding between Rule Elements

    Declaration
    public const float k_PaddingBetweenRules = 26F
    Field Value
    Type Description
    Single

    k_SingleLineHeight

    Single line height

    Declaration
    public const float k_SingleLineHeight = 16F
    Field Value
    Type Description
    Single

    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
    UnityEditor.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
    Boolean

    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()

    DestroyPreview()

    Handles cleanup for the Preview GUI

    Declaration
    protected virtual void DestroyPreview()

    DrawCustomFields(Boolean)

    Draw editor fields for custom properties for the RuleTile

    Declaration
    public void DrawCustomFields(bool isOverrideInstance)
    Parameters
    Type Name Description
    Boolean 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
    Int32

    Returns the index for a Rule with the RuleTile to display an arrow.

    GetElementHeight(RuleTile.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
    Single

    GUI element height for a TilingRule

    GetElementHeight(RuleTile.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
    Single

    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
    Int32

    The offset change for a mouse click input

    GetRuleGUIBounds(BoundsInt, RuleTile.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
    Boolean

    True

    Overrides
    Editor.HasPreviewGUI()

    ListUpdated(ReorderableList)

    Callback when the Rule list is updated

    Declaration
    public void ListUpdated(ReorderableList list)
    Parameters
    Type Name Description
    UnityEditorInternal.ReorderableList list

    Reorderable list for Rules

    OnDisable()

    OnDisable for the RuleTileEditor

    Declaration
    public virtual void OnDisable()

    OnDrawElement(Rect, Int32, Boolean, Boolean)

    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

    Int32 index

    Index of the Rule Element to draw

    Boolean isactive

    Whether the Rule Element is active

    Boolean 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
    Editor.OnInspectorGUI()

    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
    Editor.OnPreviewGUI(Rect, GUIStyle)

    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[], Int32, Int32)

    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

    Int32 width

    Width of the static preview

    Int32 height

    Height of the static preview

    Returns
    Type Description
    Texture2D

    Texture2D containing static preview for the RuleTile asset

    Overrides
    Editor.RenderStaticPreview(String, Object[], Int32, Int32)

    RuleInspectorOnGUI(Rect, RuleTile.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(RuleTile.TilingRule, Dictionary<Vector3Int, Int32>, 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, Int32> 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, RuleTile.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, RuleTile.TilingRule, Dictionary<Vector3Int, Int32>, 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, Int32> neighbors

    A dictionary of neighbors

    Vector3Int position

    The relative position of the neighbor matching Rule

    RuleOnGUI(Rect, Vector3Int, Int32)

    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

    Int32 neighbor

    The index to the neighbor matching criteria

    RuleTooltipOnGUI(Rect, Int32)

    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

    Int32 neighbor

    The index to the neighbor matching criteria

    RuleTransformOnGUI(Rect, RuleTile.TilingRuleOutput.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, RuleTile.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, RuleTile.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

    In This Article
    • Fields
      • extendNeighbor
      • k_DefaultElementHeight
      • k_LabelWidth
      • k_PaddingBetweenRules
      • k_SingleLineHeight
      • m_PreviewGrid
      • m_PreviewTilemapRenderers
      • m_PreviewTilemaps
      • m_PreviewUtility
    • Properties
      • arrows
      • autoTransforms
      • tile
    • Methods
      • Base64ToTexture(String)
      • ContainsMousePosition(Rect)
      • CopyAllRules(MenuCommand)
      • CreatePreview()
      • DestroyPreview()
      • DrawCustomFields(Boolean)
      • FindAffectedOverrideTiles(RuleTile)
      • GetArrowIndex(Vector3Int)
      • GetElementHeight(RuleTile.TilingRule)
      • GetElementHeight(RuleTile.TilingRuleOutput)
      • GetMatrixSize(BoundsInt)
      • GetMouseChange()
      • GetRuleGUIBounds(BoundsInt, RuleTile.TilingRule)
      • HasPreviewGUI()
      • ListUpdated(ReorderableList)
      • OnDisable()
      • OnDrawElement(Rect, Int32, Boolean, Boolean)
      • OnDrawHeader(Rect)
      • OnEnable()
      • OnInspectorGUI()
      • OnPreviewGUI(Rect, GUIStyle)
      • PasteRules(MenuCommand)
      • RenderStaticPreview(String, Object[], Int32, Int32)
      • RuleInspectorOnGUI(Rect, RuleTile.TilingRuleOutput)
      • RuleMatrixIconOnGUI(RuleTile.TilingRule, Dictionary<Vector3Int, Int32>, Vector3Int, Rect)
      • RuleMatrixOnGUI(RuleTile, Rect, BoundsInt, RuleTile.TilingRule)
      • RuleNeighborUpdate(Rect, RuleTile.TilingRule, Dictionary<Vector3Int, Int32>, Vector3Int)
      • RuleOnGUI(Rect, Vector3Int, Int32)
      • RuleTooltipOnGUI(Rect, Int32)
      • RuleTransformOnGUI(Rect, RuleTile.TilingRuleOutput.Transform)
      • RuleTransformUpdate(Rect, RuleTile.TilingRule)
      • SaveTile()
      • SpriteOnGUI(Rect, RuleTile.TilingRuleOutput)
      • UpdateAffectedOverrideTiles(RuleTile)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • 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 18 October 2023