public void BuildCollection() { if (collection != null) { Destroy(collection); } if (textSprite != null) { Destroy(textSprite); } String name = "SCROLL_COLLECTION"; collection = new tk2dSpriteCollectionData(); collection.assetName = name; collection.allowMultipleAtlases = false; collection.buildKey = 0x0ade; collection.dataGuid = name + "_DATAGUID"; collection.spriteCollectionGUID = name + "_GUID"; collection.spriteCollectionName = name; collection.spriteDefinitions = new tk2dSpriteDefinition[0]; DontDestroyOnLoad(collection); gunID = SpriteBuilder.AddSpriteToCollection(gunTextSpritePath, collection); itemID = SpriteBuilder.AddSpriteToCollection(itemTextSpritePath, collection); textSprite = SpriteBuilder.SpriteFromResource(ScrollOfApproxKnowledge.gunTextSpritePath).GetComponent <tk2dSprite>(); textSprite.UsesSpriteCollection(collection); baseScale = textSprite.scale; textSprite.scale = Vector2.zero; }
/// <summary> /// Returns an object with a tk2dSprite component with the texture provided /// </summary> public static GameObject SpriteFromTexture(tk2dSpriteCollectionData collection, Texture2D texture, string spriteName) { GameObject obj = new GameObject(); tk2dSprite sprite = obj.AddComponent <tk2dSprite>(); int id = SpriteBuilder.AddSpriteToCollection(spriteName, collection); sprite.SetSprite(collection, id); sprite.SortingOrder = 0; sprite.UsesSpriteCollection(collection); return(obj); }