public string GetExportPath(string definitionName, string scenePath, bool is_animation) { ExporterConfig exporterConfig = (ExporterConfig) new ConfigManager().GetCategory(SettingsCategories.EXPORTER); ProjectConfig projectConfig = (ProjectConfig) new ConfigManager().GetCategory(SettingsCategories.PROJECT); string exportPattern = exporterConfig.ExportPattern; string returnDirectory = ""; if (UseExportPath && ExportPath != string.Empty) { returnDirectory = ExportPath; if (returnDirectory.Contains("..")) { returnDirectory = returnDirectory.Replace("..", projectConfig.GetContentRoot()); } } else if (exportPattern.Contains("<CONTENT_ROOT>")) { returnDirectory = exportPattern.Replace("<CONTENT_ROOT>", projectConfig.GetContentRoot()); } else if (exportPattern.Contains("<PROJECT_ROOT>")) { returnDirectory = exportPattern.Replace("<PROJECT_ROOT>", projectConfig.GetProjectRoot()); } else { string sceneDirectory = Path.GetDirectoryName(scenePath); returnDirectory = Path.GetDirectoryName(scenePath); int nextIndex = 0; List <string> splitPattern = new List <string>(exportPattern.Split(Path.DirectorySeparatorChar)); foreach (string pattern in splitPattern) { nextIndex += 1; if (pattern == "..") // Remove 1 directory from the path { int splitIndex = returnDirectory.LastIndexOf(Path.DirectorySeparatorChar); returnDirectory = returnDirectory.Substring(0, splitIndex); } else if (pattern == "...") // Search back until we find the directory name that matches the next pattern { string nextPattern = nextIndex < splitPattern.Count ? splitPattern[nextIndex] : string.Empty; if (nextPattern != string.Empty && returnDirectory.Contains(nextPattern)) { List <string> splitReturnDirectory = new List <string>(returnDirectory.Split(Path.DirectorySeparatorChar)); string driveLetter = string.Empty; if (splitReturnDirectory[0].Contains(":")) { driveLetter = splitReturnDirectory[0]; splitReturnDirectory.RemoveAt(0); } int patternIndex = splitReturnDirectory.IndexOf(nextPattern); returnDirectory = Path.Combine(splitReturnDirectory.GetRange(0, patternIndex).ToArray()); if (driveLetter != string.Empty) { returnDirectory = driveLetter + Path.DirectorySeparatorChar + returnDirectory; } } } else // Add the pattern to the path as a new directory { returnDirectory = Path.Combine(returnDirectory, pattern); } } if (exporterConfig.MatchDirectory == true && returnDirectory.Length < sceneDirectory.Length) { string removedDirectory = sceneDirectory.Remove(0, returnDirectory.Length + 1); // + 1 accounts for 0 based index and 1 based length count removedDirectory = removedDirectory.TrimStart(Path.DirectorySeparatorChar); List <string> removedList = new List <string>(removedDirectory.Split(Path.DirectorySeparatorChar)); string[] addList = removedList.GetRange(1, removedList.Count - 1).ToArray(); foreach (string addDirectory in addList) { returnDirectory = Path.Combine(returnDirectory, addDirectory); } } } string fileNamePattern = exporterConfig.FileNamePattern; string animationExportName = fileNamePattern.Replace("<Asset>", Name).Replace("<Definition>", definitionName); string exportName = is_animation ? (animationExportName + ".fbx") : (Name + ".fbx"); return(Path.Combine(returnDirectory, exportName).ToString().Replace("/", Path.DirectorySeparatorChar.ToString())); }