/// <summary> /// Adds a sprite (from a resource) to a collection /// </summary> /// <returns>The spriteID of the defintion in the collection</returns> public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection) { string extension = !resourcePath.EndsWith(".png") ? ".png" : ""; resourcePath += extension; var texture = ResourceExtractor.GetTextureFromResource(resourcePath); //Get Texture var definition = ConstructDefinition(texture); //Generate definition definition.name = texture.name; //naming the definition is actually extremely important return(AddSpriteToCollection(definition, collection)); }
/// <summary> /// Returns an object with a tk2dSprite component with the /// texture of an embedded resource /// </summary> public static GameObject SpriteFromResource(tk2dSpriteCollectionData collection, string spriteName) { string extension = !spriteName.EndsWith(".png") ? ".png" : ""; string resourcePath = spriteName + extension; var texture = ResourceExtractor.GetTextureFromResource(resourcePath); if (texture == null) { return(null); } return(SpriteFromTexture(collection, texture, resourcePath)); }