public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection) { string str = (!resourcePath.EndsWith(".png")) ? ".png" : ""; resourcePath += str; Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(resourcePath); tk2dSpriteDefinition tk2dSpriteDefinition = ConstructDefinition(textureFromResource); tk2dSpriteDefinition.name = textureFromResource.name; return(AddSpriteToCollection(tk2dSpriteDefinition, collection)); }
public static void AddSpritesToCollection(List <string> ResourceNames, tk2dSpriteCollectionData collection) { foreach (string ResourceName in ResourceNames) { string resourcePath = ResourceName; string str = (!resourcePath.EndsWith(".png")) ? ".png" : ""; resourcePath += str; Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(resourcePath); tk2dSpriteDefinition tk2dSpriteDefinition = ConstructDefinition(textureFromResource); tk2dSpriteDefinition.name = textureFromResource.name; AddSpriteToCollection(tk2dSpriteDefinition, collection); } }
public static GameObject SpriteFromResource(string spriteName, GameObject obj = null, bool copyFromExisting = true) { string str = (!spriteName.EndsWith(".png")) ? ".png" : ""; string text = spriteName + str; Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(text); bool flag = textureFromResource == null; GameObject result; if (flag) { result = null; } else { result = SpriteFromTexture(textureFromResource, text, obj, copyFromExisting); } return(result); }