// Export private void proceedToExportAndUpload() { if (System.IO.File.Exists(zipPath)) { System.IO.File.Delete(zipPath); } // "Sketchfab Plugin (Unity " + Application.unityVersion + ")" var exporter = new GLTFEditorExporter(opt_exportSelection ? GLTFUtils.getSelectedTransforms() : GLTFUtils.getSceneTransforms()); exporter.setProgressCallback(OnExportProgress); exporter.setExportFinishCallback(OnExportFinish); exporter.enableAnimation(opt_exportAnimation); exporter.SaveGLTFandBin(Path.GetDirectoryName(exportPath), Path.GetFileNameWithoutExtension(exportPath)); GLTFUtils.buildZip(exporter.getExportedFilesList(), Path.Combine(Path.GetDirectoryName(exportPath), "Unity2Skfb.zip"), true); if (File.Exists(zipPath)) { bool shouldUpload = checkFileSize(zipPath); if (!shouldUpload) { shouldUpload = EditorUtility.DisplayDialog("Error", "The export exceed the max file size allowed by your current account type", "Continue", "Cancel"); } publishModel(zipPath); } else { Debug.Log("Zip file has not been generated. Aborting publish."); } }
/** * Generate a non-zipped GLTF file with all folders etc */ public static Tuple <string, string, string> GenerateGLTF(GameObject selectedObject) { string selectionName = selectedObject.name; string fullpath = EditorUtility.SaveFilePanel("glTF Export Path", PlattarExporterOptions.LastEditorPath, selectionName, "zip"); PlattarExporterOptions.LastEditorPath = Path.GetDirectoryName(fullpath); string selectedName = Path.GetFileNameWithoutExtension(fullpath); var path = PlattarExporterOptions.LastEditorPath; if (!string.IsNullOrEmpty(path)) { var newpath = path + "/" + selectionName + "_export_gltf"; DirectoryInfo info = Directory.CreateDirectory(newpath); if (info.Exists) { if (PlattarExporterOptions.ExportAnimations == true) { var exporter = new GLTFEditorExporter(new Transform[] { selectedObject.transform }); exporter.SaveGLTFandBin(newpath, selectionName); } else { var exporter = new GLTFSceneExporter(new Transform[] { selectedObject.transform }); exporter.SaveGLTFandBin(newpath, selectionName); } return(new Tuple <string, string, string>(path, newpath, selectedName)); } EditorUtility.DisplayDialog("Failed Export", "GLTF Could not be exported, could not create export path", "OK"); } else { EditorGUILayout.HelpBox("Failed to export since the path is invalid", MessageType.Error); EditorUtility.DisplayDialog("Failed Export", "GLTF Could not be exported, invalid export path provided", "OK"); } return(null); }