Sprite Collection Data. More...
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. |
Sprite Collection Data.
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.
tk2dSpriteDefinition tk2dSpriteCollectionData.GetSpriteDefinition | ( | string | name | ) |
Resolves a sprite name and returns a reference to a sprite definition.
name | Case sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension |
int tk2dSpriteCollectionData.GetSpriteIdByName | ( | string | name | ) |
Resolves a sprite name and returns a unique id for the sprite.
name | Case 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.
name | Case sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension |
defaultValue | The 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.
bool tk2dSpriteCollectionData.IsValidSpriteId | ( | int | id | ) |
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.
Specifies if sprites span multiple atlases.
string tk2dSpriteCollectionData.assetName = "" |
Asset Name, used to load the asset.
string tk2dSpriteCollectionData.dataGuid = "" |
GUID of this object, used with tk2dIndex
float tk2dSpriteCollectionData.halfTargetHeight = 1.0f |
Target height used to generate the sprite collection.
bool tk2dSpriteCollectionData.hasPlatformData = false |
When true, spriteCollectionPlatforms & PlatformGUIDs are expected to have sensible data.
float tk2dSpriteCollectionData.invOrthoSize = 1.0f |
The size of the inv ortho size used to generate the sprite collection.
bool tk2dSpriteCollectionData.loadable = false |
Is this asset loadable using tk2dSystem.
bool tk2dSpriteCollectionData.managedSpriteCollection = false |
When true, sprite collection will not be directly selectable.
Material tk2dSpriteCollectionData.material |
Only exists for backwards compatibility. Do not use or rely on this.
Material [] tk2dSpriteCollectionData.materials |
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.
string [] tk2dSpriteCollectionData.spriteCollectionPlatformGUIDs = null |
Returns an array of GUIDs, each referring to an actual tk2dSpriteCollectionData object This object contains the actual sprite collection for the platform.
string [] tk2dSpriteCollectionData.spriteCollectionPlatforms = null |
Returns an array of platform names.
An array of sprite definitions.
Texture [] tk2dSpriteCollectionData.textures |
An array of all textures used by this sprite collection.
int tk2dSpriteCollectionData.Count [get] |
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.