/******************************************** // C# Example // Nicholas M Covington // http://www.enemcee.com // Itsnickcovington@gmail.com // This is a small part of a library written to handle the export of sprites from our large library of assets. // This class returns the name and path of all files expected to be created from a export. // It was implemented to be able to determine from data, which exported assets should exist, which are not present // on our Dropbox depot, and which assets have not yet been exported or are missing. **********************************************/ using System; using System.Collections.Generic; using System.Text; using System.IO; namespace FTXImportExport { // generates a list of all files that should exist when a file is exported. public abstract class FTXExportDescriptor { public string id; public string project; public string type; public string[] fileNames; public string[] dropboxFileNames; public abstract void GenerateExportedFiles(string project = "SomeProjectName"); } // sprite implementation of export results. public class FTXSpriteExportDescriptor : FTXExportDescriptor { public SpriteExportParams spriteParams; // CONSTRUCTORS public FTXSpriteExportDescriptor() { this.type = "spritesheet"; } public FTXSpriteExportDescriptor(string name) { this.id = name; this.type = "spritesheet"; } public FTXSpriteExportDescriptor(string name, string project) { this.id = name; this.project = project; //this.GenerateExportedFiles(project); this.type = "spritesheet"; } public FTXSpriteExportDescriptor(string name, string project, SpriteExportParams p) { this.id = name; this.project = project; this.type = "spritesheet"; this.spriteParams = p; this.GenerateExportedFiles(project); } // METHODS private void LoadProjectsIfUnloaded() { if (!ProjectSettings.isLoaded) { ProjectSettings.loadProject(this.project); } } private string GetSpriteTarget() { this.LoadProjectsIfUnloaded(); return ProjectSettings.spriteTarget; } private string GetDropboxTarget() { this.LoadProjectsIfUnloaded(); return ProjectSettings.dropboxSpriteTarget; } private void GenFilesPerArmature(string dirRoot, string armatureName, List target) { target.Add(String.Format("{2}\\{0}_{1}.tga", this.id, armatureName, dirRoot)); target.Add(String.Format("{2}\\{0}_{1}.png", this.id, armatureName, dirRoot)); if (this.spriteParams.doMatteMask) { target.Add(String.Format("{3}\\{0}_{1}{2}.tga", this.id, armatureName, this.spriteParams.mattePostFix, dirRoot)); target.Add(String.Format("{3}\\{0}_{1}{2}.png", this.id, armatureName, this.spriteParams.mattePostFix, dirRoot)); } } // Using properties of our static class "ProjectSettings", generateExportedFiles // constructs paths from strings representing the output paths and files of our specified asset. public override void GenerateExportedFiles(string p = "SomeProjectName") { this.project = p; string exportTarget = this.GetSpriteTarget(); string dropboxTarget = this.GetDropboxTarget(); List files = new List(); List dropboxFiles = new List(); foreach (string armature in this.spriteParams.armatures) { string primaryName = armature.Split(',')[0]; string directory = String.Format("{0}{1}_{2}", exportTarget, this.id, primaryName); string dropboxDir = String.Format("{0}{1}_{2}", dropboxTarget, this.id, primaryName); GenFilesPerArmature(directory, primaryName, files ); GenFilesPerArmature(dropboxDir, primaryName, dropboxFiles); } this.fileNames = new string[files.Count]; this.dropboxFileNames = new string[files.Count]; for (int i = 0; i < files.Count; i++) { this.fileNames[i] = files[i]; this.dropboxFileNames[i] = dropboxFiles[i]; } } } }