docs.unity.cn
    Show / Hide Table of Contents

    Interface ISpriteEditor

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

    Namespace: UnityEditor.U2D.Sprites
    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
    Boolean

    enableMouseMoveEvent

    Indicates if ISpriteEditor should be interested in mouse move events.

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

    mipLevel

    The current Mip Level of the Texture displayed in ISpriteEditor view

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

    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
    Boolean

    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
    Single

    Methods

    ApplyOrRevertModification(Boolean)

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

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

    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.

    HandleSpriteSelection()

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

    Declaration
    bool HandleSpriteSelection()
    Returns
    Type Description
    Boolean

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

    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.

    Int32 width

    The width dimension to render the preview texture.

    Int32 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.

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on 09 May 2022
    Terms of use