C# Class Spine.Unity.Modules.AttachmentTools.SpriteAtlasRegionExtensions

显示文件 Open project: EsotericSoftware/spine-runtimes

Public Methods

Method Description
GetRepackedSkin ( this o, string newName, Shader shader, Material &m, Texture2D &t, int maxAtlasSize = 1024, int padding = 2 ) : Skin

Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin.

No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.

ToAtlasRegion ( this s, AtlasPage page ) : AtlasRegion

Creates a Spine.AtlasRegion from a UnityEngine.Sprite.

ToAtlasRegion ( this s, Material material ) : AtlasRegion

Creates a Spine.AtlasRegion from a UnityEngine.Sprite. This creates a new AtlasPage object for every AtlasRegion you create. You can centralize Material control by creating a shared atlas page using Material.ToSpineAtlasPage and using the sprite.ToAtlasRegion(AtlasPage) overload.

ToAtlasRegionPMAClone ( this s, Shader shader ) : AtlasRegion

Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate of the Sprite's texture data.

ToSpineAtlasPage ( this m ) : AtlasPage

Creates a new Spine.AtlasPage from a UnityEngine.Material. If the material has a preassigned texture, the page width and height will be set.

ToSprite ( this ar, float pixelsPerUnit = 100 ) : Sprite

Private Methods

Method Description
ApplyPMA ( this texture, bool applyImmediately = true ) : void
GetAtlasRegion ( this a ) : AtlasRegion

Tries to get the backing AtlasRegion of an attachment if it is renderable. Returns null for non-renderable attachments.

GetMainTexture ( this region ) : Texture2D

Convenience method for getting the main texture of the material of the page of the region.

GetSpineAtlasRect ( this region, bool includeRotate = true ) : Rect

Returns a Rect of the AtlasRegion according to Spine texture coordinates. (x-right, y-down)

GetUnityRect ( this region ) : Rect

Gets the Rect of an AtlasRegion according to Unity texture coordinates (x-right, y-up). This overload relies on region.page.height being correctly set.

GetUnityRect ( this region, int textureHeight ) : Rect

Gets the Rect of an AtlasRegion according to Unity texture coordinates (x-right, y-up).

InverseLerp ( float a, float b, float value ) : float
IsRenderable ( Attachment a ) : bool
SpineUnityFlipRect ( this rect, int textureHeight ) : Rect

Get a rect with flipped Y so that a Spine atlas rect gets converted to a Unity Sprite rect and vice versa.

TextureRectToUVRect ( Rect textureRect, int texWidth, int texHeight ) : Rect

Normalize a texture Rect into UV coordinates.

ToAtlasRegion ( this s, bool isolatedTexture = false ) : AtlasRegion
ToTexture ( this ar, bool applyImmediately = true ) : Texture2D
UVRectToAtlasRegion ( Rect uvRect, string name, AtlasPage page, float offsetX, float offsetY, bool rotate ) : AtlasRegion

Creates a new Spine AtlasRegion according to a Unity UV Rect (x-right, y-up, uv-normalized).

UVRectToTextureRect ( Rect uvRect, int texWidth, int texHeight ) : Rect

Denormalize a uvRect into a texture-space Rect.

Method Details

GetRepackedSkin() public static method

Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin.
No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
public static GetRepackedSkin ( this o, string newName, Shader shader, Material &m, Texture2D &t, int maxAtlasSize = 1024, int padding = 2 ) : Skin
o this
newName string
shader UnityEngine.Shader
m UnityEngine.Material
t UnityEngine.Texture2D
maxAtlasSize int
padding int
return Skin

ToAtlasRegion() public static method

Creates a Spine.AtlasRegion from a UnityEngine.Sprite.
public static ToAtlasRegion ( this s, AtlasPage page ) : AtlasRegion
s this
page AtlasPage
return AtlasRegion

ToAtlasRegion() public static method

Creates a Spine.AtlasRegion from a UnityEngine.Sprite. This creates a new AtlasPage object for every AtlasRegion you create. You can centralize Material control by creating a shared atlas page using Material.ToSpineAtlasPage and using the sprite.ToAtlasRegion(AtlasPage) overload.
public static ToAtlasRegion ( this s, Material material ) : AtlasRegion
s this
material UnityEngine.Material
return AtlasRegion

ToAtlasRegionPMAClone() public static method

Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate of the Sprite's texture data.
public static ToAtlasRegionPMAClone ( this s, Shader shader ) : AtlasRegion
s this
shader UnityEngine.Shader
return AtlasRegion

ToSpineAtlasPage() public static method

Creates a new Spine.AtlasPage from a UnityEngine.Material. If the material has a preassigned texture, the page width and height will be set.
public static ToSpineAtlasPage ( this m ) : AtlasPage
m this
return AtlasPage

ToSprite() public static method

public static ToSprite ( this ar, float pixelsPerUnit = 100 ) : Sprite
ar this
pixelsPerUnit float
return UnityEngine.Sprite