using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.U2D; using UnityObject = UnityEngine.Object; namespace UnityEditor.U2D.Sprites { /// An interface that allows Sprite Editor Window to edit Sprite data for user custom importer. /// Implement this interface for [[ScriptedImporter]] to leverage on Sprite Editor Window to edit Sprite data. public interface ISpriteEditorDataProvider { /// SpriteImportMode to indicate how Sprite data will be imported. SpriteImportMode spriteImportMode { get; } /// The number of pixels in the sprite that correspond to one unit in world space. float pixelsPerUnit { get; } /// The object that this data provider is acquiring its data from. UnityObject targetObject { get; } /// Returns an array of SpriteRect representing Sprite data the provider has. /// Array of SpriteRect. SpriteRect[] GetSpriteRects(); /// Sets the data provider's current SpriteRect. /// Updated array of SpriteRect. void SetSpriteRects(SpriteRect[] spriteRects); /// Applying any changed data. void Apply(); /// Allows the data provider to initialize any data if needed. void InitSpriteEditorDataProvider(); /// Gets other data providers that might be supported by ISpriteEditorDataProvider.targetObject. /// The data provider type to acquire. /// Data provider type. T GetDataProvider() where T : class; /// Queries if ISpriteEditorDataProvider.targetObject supports the data provider type. /// Data provider type. /// True if supports, false otherwise. bool HasDataProvider(Type type); } /// /// Data Provider interface that deals with Sprite Bone data. /// public interface ISpriteBoneDataProvider { /// /// Returns the list of SpriteBone for the corresponding Sprite ID. /// /// Sprite ID. /// The list of SpriteBone associated with the Sprite List GetBones(GUID guid); /// Sets a new set of SpriteBone for the corresponding Sprite ID. /// Sprite ID. /// List of SpriteBone to associate with the Sprite. void SetBones(GUID guid, List bones); } /// Data provider that provides the outline data for SpriteRect. /// The outline data is used to tessellate a Sprite's mesh. public interface ISpriteOutlineDataProvider { /// Given a GUID, returns the outline data used for tessellating the SpriteRect. /// GUID of the SpriteRect. /// Outline data for theSpriteRect. List GetOutlines(GUID guid); /// Given a GUID, sets the outline data used for tessellating the SpriteRect. /// GUID of the SpriteRect. /// Outline data for theSpriteRect. void SetOutlines(GUID guid, List data); /// Given a GUID, returns the tessellation detail.Tessellation value should be between 0 to 1. /// GUID of the SpriteRect. /// The tessellation value. float GetTessellationDetail(GUID guid); /// Given a GUID, sets the tessellation detail.Tessellation value should be between 0 to 1. /// GUID of the SpriteRect. /// The tessellation value. void SetTessellationDetail(GUID guid, float value); } /// Data provider that provides the Physics outline data for SpriteRect. /// Uses the outline data to generate the Sprite's Physics shape for Polygon Collider 2D. public interface ISpritePhysicsOutlineDataProvider { /// Given a GUID, returns the Physics outline data used for the SpriteRect. /// GUID of the SpriteRect. /// Physics outline data for the SpriteRect. List GetOutlines(GUID guid); /// Given a GUID, sets the Physics outline data used for the SpriteRect. /// GUID of the SpriteRect. /// Physics outline data for the SpriteRect. void SetOutlines(GUID guid, List data); /// Given a GUID, returns the tessellation detail.Tessellation value should be between 0 to 1. /// GUID of the SpriteRect. /// The tessellation value. float GetTessellationDetail(GUID guid); /// Given a GUID, sets the tessellation detail.Tessellation value should be between 0 to 1. /// GUID of the SpriteRect. /// The tessellation value. void SetTessellationDetail(GUID guid, float value); } /// Data provider that provides texture data needed for Sprite Editor Window. public interface ITextureDataProvider { /// Texture2D representation of the data provider. Texture2D texture { get; } /// Texture2D that represents the preview for ITextureDataProvider.texture. Texture2D previewTexture { get; } /// The actual width and height of the texture data. /// Out value for width. /// Out value for height. void GetTextureActualWidthAndHeight(out int width , out int height); /// Readable version of ITextureProvider.texture. /// Texture2D that is readable. Texture2D GetReadableTexture2D(); } /// Data provider that provides secoondary texture data needed for Sprite Editor Window. public interface ISecondaryTextureDataProvider { /// /// Get set method for an array of SecondarySpriteTexture in the Data Provider /// SecondarySpriteTexture[] textures { get; set; } } /// A structure that contains meta data about vertices in a Sprite. [Serializable] public struct Vertex2DMetaData { /// The position of the vertex. public Vector2 position; /// The BoneWeight of the vertex. public BoneWeight boneWeight; } /// Data Provider interface that deals with Sprite mesh data. public interface ISpriteMeshDataProvider { /// Returns the list of vertex datas for the corresponding Sprite ID. /// Sprite ID. Vertex2DMetaData[] GetVertices(GUID guid); /// Sets a new list of vertices for the corresponding Sprite ID. /// Sprite ID. void SetVertices(GUID guid, Vertex2DMetaData[] vertices); /// Returns the list of mesh index for the corresponding Sprite ID. /// Sprite ID. int[] GetIndices(GUID guid); /// Sets a new list of indices for the corresponding Sprite ID. /// Sprite ID. void SetIndices(GUID guid, int[] indices); /// Returns the list of mesh edges for the corresponding Sprite ID. /// Sprite ID. Vector2Int[] GetEdges(GUID guid); /// Sets a new list of edges for the corresponding Sprite ID. /// Sprite ID. void SetEdges(GUID guid, Vector2Int[] edges); } }