private void ImportTextures() { ShowProgress("Copying Textures", 0.25f); string textureImportRoot = ImportUtil.GetTexturePathFromImportLocation(originalFilePath); Directory.CreateDirectory(texturePath); string[] modifiers = { "", "-glow", "-shine", "-normal" }; // if we dont have the texture, and it does not already exist, copy it in for (int i = 0; i < model.TextureCount; i++) { for (int j = 0; j < modifiers.Length; j++) { string[] pathSegments = { textureImportRoot, model.GetTextureNameByIndex(i) + modifiers[j] }; string pathToTexture = ImportUtil.MakePath(pathSegments); string textureName = model.GetTextureNameByIndex(i) + modifiers[j]; if (ImportUtil.TryToImportTexture(pathToTexture, GetTextureAssetPath(textureName))) { break; } } } AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); }
public Importer(string originalFilePath, string progressTitle = "Importing") { this.originalFilePath = originalFilePath; this.progressTitle = progressTitle; modelName = ImportUtil.CultureInfo.TextInfo.ToTitleCase(Path.GetFileNameWithoutExtension(originalFilePath) .ToLower()); string importPath = GetImportPath(); texturePath = Path.Combine(importPath, "Textures"); materialPath = Path.Combine(importPath, "Materials"); meshPath = Path.Combine(importPath, "Meshes"); AssetRootPath = "Assets/Freespace Assets/" + ImportUtil.GetShipClassFromPath(originalFilePath) + "/" + modelName; PrefabRootPath = ImportUtil.MakePath(new[] { Application.dataPath, "Freespace Prefabs", ImportUtil.GetShipClassFromPath(originalFilePath) }); Directory.CreateDirectory(PrefabRootPath); materialMap = new Dictionary <int, Material>(); processedSubObjects = new HashSet <SubObject>(); }