private static string GetMeshFormat(ExportMeshFormat format) { switch (format) { case ExportMeshFormat.FBX: return(".fbx"); case ExportMeshFormat.OBJ_NotWorking: return(".obj"); default: return(""); } }
private static void ExportMesh(Mesh mesh, string path, ExportMeshFormat format, object data, bool switchUv) { string formatName = GetMeshFormat(format); string finalPath = path + formatName; if (File.Exists(finalPath)) { File.Delete(finalPath); } switch (format) { case ExportMeshFormat.FBX: FBXExporter.ExportMesh(mesh, finalPath, switchUv); break; case ExportMeshFormat.OBJ_NotWorking: break; } }
public MeshExporter GetMeshExporter(ExportMeshFormat format) { return(meshExporters[format]); }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Export Path"); exportPath = EditorGUILayout.TextField(exportPath); if (GUILayout.Button("...")) { // search for a folder exportPath = EditorUtility.OpenFolderPanel("JanusVR Export Folder", exportPath, @"C:\"); } EditorGUILayout.EndHorizontal(); defaultMeshFormat = (ExportMeshFormat)EditorGUILayout.EnumPopup("Default Mesh Format", defaultMeshFormat); defaultTexFormat = (ImageFormatEnum)EditorGUILayout.EnumPopup("Default Textures Format", defaultTexFormat); filterMode = (TextureFilterMode)EditorGUILayout.EnumPopup("Texture Filter", filterMode); defaultQuality = EditorGUILayout.IntSlider("Default Textures Quality", defaultQuality, 0, 100); uniformScale = EditorGUILayout.FloatField("Uniform Scale", uniformScale); exportMaterials = EditorGUILayout.Toggle("Export Materials", exportMaterials); exportSkybox = EditorGUILayout.Toggle("Export Skybox (6-sided)", exportSkybox); lightmapExportType = (LightmapExportType)EditorGUILayout.EnumPopup("Lightmap Type", lightmapExportType); if (lightmapExportType != LightmapExportType.None) { maxLightMapResolution = Math.Max(32, EditorGUILayout.IntField("Max Lightmap Resolution", maxLightMapResolution)); } if (!string.IsNullOrEmpty(exportPath)) { if (GUILayout.Button("Start Export")) { PreExport(); } } scrollPosition = GUILayout.BeginScrollView(scrollPosition); if (exported != null) { perTextureOptions = EditorGUILayout.Foldout(perTextureOptions, "Per Texture Options"); Rect last = GUILayoutUtility.GetLastRect(); last.y = last.y + last.height; float size = Math.Min(Screen.width * 0.3f, Screen.height * 0.1f); float half = Screen.width * 0.5f; if (perTextureOptions) { for (int i = 0; i < texturesExportedData.Count; i++) { TextureExportData tex = texturesExportedData[i]; Rect r = GUILayoutUtility.GetRect(Screen.width, size * 1.05f); GUI.DrawTexture(new Rect(size * 0.1f, r.y, size, size), tex.Preview); GUI.Label(new Rect(size * 1.1f, r.y, half - size, size), tex.Texture.name); float x1 = half * 1.3f; float y = r.y; float wid = half * 0.6f; GUI.Label(new Rect(half, y, half * 0.3f, last.height), "Format"); tex.Format = (ImageFormatEnum)EditorGUI.EnumPopup(new Rect(x1, y, wid, last.height), tex.Format); y += last.height; GUI.Label(new Rect(half, y, half * 0.3f, last.height), "Resolution"); tex.Resolution = EditorGUI.IntSlider(new Rect(x1, y, wid, last.height), tex.Resolution, 32, tex.Texture.width); y += last.height; GUI.Label(new Rect(half, y, half * 0.3f, last.height), "Export Alpha"); tex.ExportAlpha = EditorGUI.Toggle(new Rect(x1, y, wid, last.height), tex.ExportAlpha); y += last.height; if (SupportsQuality(tex.Format)) { GUI.Label(new Rect(half, y, half * 0.3f, last.height), "Quality"); tex.Quality = EditorGUI.IntSlider(new Rect(x1, y, wid, last.height), tex.Quality, 0, 100); } } } //perModelOptions = EditorGUILayout.Foldout(perModelOptions, "Per Model Options"); //if (perModelOptions) //{ // for (int i = 0; i < meshesExportedData.Count; i++) // { // MeshExportData model = meshesExportedData[i]; // string name = meshesNames[model.Mesh]; // Rect r = GUILayoutUtility.GetRect(Screen.width, size * 1.05f); // //GUI.DrawTexture(new Rect(size * 0.1f, r.y, size, size), model.Preview); // GUI.Label(new Rect(size * 1.1f, r.y, half - size, size), name); // GUI.Label(new Rect(half, r.y, half * 0.3f, last.height), "Format"); // model.Format = (ExportMeshFormat)EditorGUI.EnumPopup(new Rect(half * 1.3f, r.y, half * 0.7f, last.height), model.Format); // } //} if (GUILayout.Button("Do Export")) { DoExport(); } } GUILayout.EndScrollView(); }