Sprite Collection Data. More...

List of all members.

Public Member Functions

int GetSpriteIdByName (string name)
 Resolves a sprite name and returns a unique id for the sprite.
int GetSpriteIdByName (string name, int defaultValue)
 Resolves a sprite name and returns a unique id for the sprite.
tk2dSpriteDefinition GetSpriteDefinition (string name)
 Resolves a sprite name and returns a reference to a sprite definition.
void InitDictionary ()
 Initializes the lookup dictionary.
bool IsValidSpriteId (int id)
 Returns true if the sprite id is valid for this sprite collection.
void InitMaterialIds ()
 Internal function to make sure all material Ids are valid. Used in the tilemap editor.
void UnloadTextures ()
 Unloads the atlas texture data in this sprite collection. This will be reloaded when the data is accessed again. Make sure all sprites using this collection have already been destroyed.

Static Public Member Functions

static tk2dSpriteCollectionData CreateFromTexture (Texture texture, tk2dSpriteCollectionSize size, string[] names, Rect[] regions, Vector2[] anchors)
 Create a sprite collection at runtime from a texture and user specified regions. Please ensure that names, regions & anchor arrays have same dimension. Use tk2dBaseSprite.CreateFromTexture if you need to create only one sprite from a texture.
static tk2dSpriteCollectionData CreateFromTexturePacker (tk2dSpriteCollectionSize size, string texturePackerData, Texture texture)
 Create a sprite collection at runtime from a texturepacker exported file. Ensure this is exported using the "2D Toolkit" export mode in TexturePacker. You can find this exporter in Assets/TK2DROOT/tk2d/Goodies/TexturePacker/Exporter You can use also use this to load sprite collections at runtime.

Public Attributes

tk2dSpriteDefinition[] spriteDefinitions
 An array of sprite definitions.
bool premultipliedAlpha
 Whether premultiplied alpha is enabled on this sprite collection. This affects how tint colors are computed.
Material material
 Only exists for backwards compatibility. Do not use or rely on this.
Material[] materials
 An array of all materials used by this sprite collection.
Texture[] textures
 An array of all textures used by this sprite collection.
TextAsset[] pngTextures = new TextAsset[0]
 An array of PNG textures used by this sprite collection.
bool allowMultipleAtlases
 Specifies if sprites span multiple atlases.
string spriteCollectionGUID
 The sprite collection GUI.
string spriteCollectionName
 The name of the sprite collection.
string assetName = ""
 Asset Name, used to load the asset.
bool loadable = false
 Is this asset loadable using tk2dSystem.
float invOrthoSize = 1.0f
 The size of the inv ortho size used to generate the sprite collection.
float halfTargetHeight = 1.0f
 Target height used to generate the sprite collection.
string dataGuid = ""
 GUID of this object, used with tk2dIndex
bool managedSpriteCollection = false
 When true, sprite collection will not be directly selectable.
bool hasPlatformData = false
 When true, spriteCollectionPlatforms & PlatformGUIDs are expected to have sensible data.
string[] spriteCollectionPlatforms = null
 Returns an array of platform names.
string[] spriteCollectionPlatformGUIDs = null
 Returns an array of GUIDs, each referring to an actual tk2dSpriteCollectionData object This object contains the actual sprite collection for the platform.

Properties

int Count [get]
 Returns the number of sprite definitions in this sprite collection.
tk2dSpriteDefinition FirstValidDefinition [get]
 Returns the first valid sprite definition.
int FirstValidDefinitionIndex [get]
 Returns the index of the first valid sprite definition.

Detailed Description

Sprite Collection Data.


Member Function Documentation

static tk2dSpriteCollectionData tk2dSpriteCollectionData.CreateFromTexture ( Texture  texture,
tk2dSpriteCollectionSize  size,
string[]  names,
Rect[]  regions,
Vector2[]  anchors 
) [static]

Create a sprite collection at runtime from a texture and user specified regions. Please ensure that names, regions & anchor arrays have same dimension. Use tk2dBaseSprite.CreateFromTexture if you need to create only one sprite from a texture.

static tk2dSpriteCollectionData tk2dSpriteCollectionData.CreateFromTexturePacker ( tk2dSpriteCollectionSize  size,
string  texturePackerData,
Texture  texture 
) [static]

Create a sprite collection at runtime from a texturepacker exported file. Ensure this is exported using the "2D Toolkit" export mode in TexturePacker. You can find this exporter in Assets/TK2DROOT/tk2d/Goodies/TexturePacker/Exporter You can use also use this to load sprite collections at runtime.

Resolves a sprite name and returns a reference to a sprite definition.

Returns:
Unique Sprite Definition. null if sprite isn't found.
Parameters:
nameCase sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension

Resolves a sprite name and returns a unique id for the sprite.

Returns:
Unique Sprite Id. 0 if sprite isn't found.
Parameters:
nameCase sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension
int tk2dSpriteCollectionData.GetSpriteIdByName ( string  name,
int  defaultValue 
)

Resolves a sprite name and returns a unique id for the sprite.

Returns:
Unique Sprite Id. defaultValue if sprite isn't found.
Parameters:
nameCase sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension
defaultValueThe value which is returned when the named sprite can't be found.

Initializes the lookup dictionary.

Internal function to make sure all material Ids are valid. Used in the tilemap editor.

Returns true if the sprite id is valid for this sprite collection.

Unloads the atlas texture data in this sprite collection. This will be reloaded when the data is accessed again. Make sure all sprites using this collection have already been destroyed.


Member Data Documentation

Specifies if sprites span multiple atlases.

Asset Name, used to load the asset.

GUID of this object, used with tk2dIndex

Target height used to generate the sprite collection.

When true, spriteCollectionPlatforms & PlatformGUIDs are expected to have sensible data.

The size of the inv ortho size used to generate the sprite collection.

Is this asset loadable using tk2dSystem.

When true, sprite collection will not be directly selectable.

Only exists for backwards compatibility. Do not use or rely on this.

An array of all materials used by this sprite collection.

TextAsset [] tk2dSpriteCollectionData.pngTextures = new TextAsset[0]

An array of PNG textures used by this sprite collection.

Whether premultiplied alpha is enabled on this sprite collection. This affects how tint colors are computed.

The sprite collection GUI.

The name of the sprite collection.

Returns an array of GUIDs, each referring to an actual tk2dSpriteCollectionData object This object contains the actual sprite collection for the platform.

Returns an array of platform names.

An array of all textures used by this sprite collection.


Property Documentation

Returns the number of sprite definitions in this sprite collection.

Returns the first valid sprite definition.

Returns the index of the first valid sprite definition.