docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface ISpriteEditor

    Interface that defines the functionality available for classes that inherits SpriteEditorModuleBase.

    Namespace: UnityEditor.U2D.Sprites
    Assembly: Unity.2D.Sprite.Editor.dll
    Syntax
    public interface ISpriteEditor
    Remarks

    Used by Sprite Editor Window to encapsulate functionality accessible for Sprite Editor modules when editing Sprite data.

    Properties

    editingDisabled

    Indicates that if Sprite data editing should be disabled; for example when the Editor is in Play Mode.

    Declaration
    bool editingDisabled { get; }
    Property Value
    Type Description
    bool

    enableMouseMoveEvent

    Indicates if ISpriteEditor should be interested in mouse move events.

    Declaration
    bool enableMouseMoveEvent { set; }
    Property Value
    Type Description
    bool

    mipLevel

    The current Mip Level of the Texture displayed in ISpriteEditor view

    Declaration
    float mipLevel { get; set; }
    Property Value
    Type Description
    float

    scrollPosition

    Current scroll position of the ISpriteEditor view. Determines the viewing location of the Texture displayed

    Declaration
    Vector2 scrollPosition { get; set; }
    Property Value
    Type Description
    Vector2

    selectedSpriteRect

    The current selected Sprite rect data.

    Declaration
    SpriteRect selectedSpriteRect { get; set; }
    Property Value
    Type Description
    SpriteRect

    showAlpha

    Whether the ISpriteEditor view is visualizing the Alpha of the Texture displayed

    Declaration
    bool showAlpha { get; set; }
    Property Value
    Type Description
    bool

    spriteRects

    Sets current available Sprite rects.

    Declaration
    List<SpriteRect> spriteRects { set; }
    Property Value
    Type Description
    List<SpriteRect>

    windowDimension

    Property that defines the window's current screen position and size.

    Declaration
    Rect windowDimension { get; }
    Property Value
    Type Description
    Rect

    zoomLevel

    Current zoom level of the ISpriteEditor view.

    Declaration
    float zoomLevel { get; set; }
    Property Value
    Type Description
    float

    Methods

    ApplyOrRevertModification(bool)

    The method will inform current active SpriteEditorModuleBase to apply or revert any data changes.

    Declaration
    void ApplyOrRevertModification(bool apply)
    Parameters
    Type Name Description
    bool apply

    True if applying. False otherwise.

    GetDataProvider<T>()

    Gets data provider that is supported by the current selected object.

    Declaration
    T GetDataProvider<T>() where T : class
    Returns
    Type Description
    T

    Instance of the data provider

    Type Parameters
    Name Description
    T

    Data provider type

    GetMainVisualContainer()

    Returns a VisualElement for attaching child VisualElement onto the main view of a ISpriteEditor.

    Declaration
    VisualElement GetMainVisualContainer()
    Returns
    Type Description
    VisualElement

    Root VisualElement for the main view.

    Remarks

    This method returns the root VisualElement for SpriteEditorModuleBase which uses the UIElement instead of IMGUI for its UI.A VisualElement that is added to this container has the same draw order as SpriteEditorModuleBase.DoPostGUI.

    GetOverlay<T>(string)

    Get the Overlay that is registered for the ISpriteEditor.

    Declaration
    T GetOverlay<T>(string overlayID) where T : Overlay
    Parameters
    Type Name Description
    string overlayID

    String ID that identifies the Overlay.

    Returns
    Type Description
    T

    The Overlay that is associated with the ISpriteEditor.

    Type Parameters
    Name Description
    T

    The Overlay type.

    GetPreviewTexture(out Texture2D, out int, out int)

    Get the current preview texture used by the ISpriteEditor

    Declaration
    void GetPreviewTexture(out Texture2D texture, out int width, out int height)
    Parameters
    Type Name Description
    Texture2D texture

    The texture that is used.

    int width

    The width dimension used render the preview texture.

    int height

    The height dimension to render the preview texture.

    GetToolbarRootElement()

    Returns a VisualElement for attaching child Toolbar onto the toolbar of a ISpriteEditor.

    Declaration
    VisualElement GetToolbarRootElement()
    Returns
    Type Description
    VisualElement

    Root VisualElement for the toolbar.

    Remarks

    This method returns the root VisualElement for SpriteEditorModuleBase which uses the UIElement instead of IMGUI for its UI.

    HandleSpriteSelection()

    The method updates ISpriteEditor.selectedSpriteRect based on current mouse down event and ISpriteEditor.spriteRects available.

    Declaration
    bool HandleSpriteSelection()
    Returns
    Type Description
    bool

    Returns true when ISpriteEditor.selectedSpriteRect is changed.

    RequestRepaint()

    Request to repaint the current view.

    Declaration
    void RequestRepaint()

    ResetZoomAndScroll()

    Resets the zoom and scroll of the Sprite Editor Windows.

    Declaration
    void ResetZoomAndScroll()

    SetDataModified()

    Indicates that there has been a change of data. In Sprite Editor Window, this enables the 'Apply' and 'Revert' button.

    Declaration
    void SetDataModified()

    SetPreviewTexture(Texture2D, int, int)

    Sets a custom texture to be used by the ISpriteEditor during setup of the editing space.

    Declaration
    void SetPreviewTexture(Texture2D texture, int width, int height)
    Parameters
    Type Name Description
    Texture2D texture

    The custom preview texture.

    int width

    The width dimension to render the preview texture.

    int height

    The height dimension to render the preview texture.

    Remarks

    When the method is called, the editing space's dimensions are set to the width and height values, affecting operations such as Zoom and Pan in the ISpriteEditor view. The preview texture is rendered as the background of the editing space.

    SetScenePreviewCallback(Action<GameObject[]>)

    Set a callback method to be called when the ISpriteEditor has GameObjects that needs to be preview in the SceneView.

    Declaration
    void SetScenePreviewCallback(Action<GameObject[]> callback)
    Parameters
    Type Name Description
    Action<GameObject[]> callback

    The callback method to be called.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)