static void ExportSelected() { string name; if (Selection.transforms.Length > 1) { name = SceneManager.GetActiveScene().name; } else if (Selection.transforms.Length == 1) { name = Selection.activeGameObject.name; } else { throw new Exception("No objects selected, cannot export."); } var exporter = new GLTFSceneExporter(Selection.transforms, RetrieveTexturePath); var path = EditorUtility.OpenFolderPanel("glTF Export Path", "", ""); if (!string.IsNullOrEmpty(path)) { exporter.SaveGLTFandBin(path, name); } }
private void proceedToExportAndUpload() { if (System.IO.File.Exists(zipPath)) { System.IO.File.Delete(zipPath); } // "Sketchfab Plugin (Unity " + Application.unityVersion + ")" var exporter = new GLTFSceneExporter(opt_exportSelection ? GLTFUtils.getSelectedTransforms() : GLTFUtils.getSceneTransforms()); 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"); } _api.publishModel(buildParameterDict(), zipPath); } else { Debug.Log("Zip file has not been generated. Aborting publish."); } }
/// <summary> /// Displays File Browser to select a file Location to save the exported glTF file /// </summary> /// <returns>IEnumerator Object</returns> public IEnumerator DisplaySaveCoroutine() { FileBrowser.SingleClickMode = true; yield return(FileBrowser.WaitForSaveDialog(FileBrowser.PickMode.FilesAndFolders, false, null, null, "Select Folder", "Save")); if (FileBrowser.Success) { string returnedPath = FileBrowser.Result[0]; Debug.Log("Export Path : " + returnedPath); var exporter = new GLTFSceneExporter(new[] { _viewerObject.transform }, RetrieveTexturePath); if (FileBrowserHelpers.DirectoryExists(returnedPath)) { string folderName = _loadFileName ?? "ExportedObject"; string finalExportPath = FileBrowserHelpers.CreateFolderInDirectory(returnedPath, folderName); Debug.Log("Final Export Path for empty filename : " + finalExportPath); exporter.SaveGLTFandBin(finalExportPath, folderName); } else { string saveFileName = FileBrowserHelpers.GetFilename(returnedPath); string folderPath = returnedPath.Substring(0, returnedPath.LastIndexOf(saveFileName)); string finalExportPath = FileBrowserHelpers.CreateFolderInDirectory(folderPath, saveFileName); Debug.Log("Final Export Path with given filename : " + finalExportPath); exporter.SaveGLTFandBin(finalExportPath, saveFileName); } } }
public void Export(Transform rootTransform, string filePath, string fileName) { if (rootTransform == null) { throw new ArgumentNullException(nameof(rootTransform)); } Transform[] childrenTransforms = new Transform[rootTransform.childCount]; for (int i = 0; i < rootTransform.childCount; i++) { childrenTransforms[i] = rootTransform.transform.GetChild(i); } GLTFSceneExporter exporter = new GLTFSceneExporter(childrenTransforms, RetrieveTexturePath); Debug.LogFormat("Exporting {0} to {1}", fileName, filePath); if (exportAsBin) { exporter.SaveGLB(filePath, fileName); } else { exporter.SaveGLTFandBin(filePath, fileName); } //string appPath = Application.dataPath; //string wwwPath = appPath.Substring(0, appPath.LastIndexOf("Assets")) + "out"; //exporter.SaveGLTFandBin(Path.Combine(wwwPath, exportedFileName), exportedFileName); }
static void ExportGLBSelected() { string name; if (Selection.transforms.Length > 1) { name = SceneManager.GetActiveScene().name; } else if (Selection.transforms.Length == 1) { name = Selection.activeGameObject.name; } else { throw new Exception("No objects selected, cannot export."); } var exportOptions = new ExportOptions { TexturePathRetriever = RetrieveTexturePath }; var exporter = new GLTFSceneExporter(Selection.transforms, exportOptions); var path = EditorUtility.SaveFolderPanel("glTF Export Path", OutputPath, ""); if (!string.IsNullOrEmpty(path)) { OutputPath = path; exporter.SaveGLB(OutputPath, name, false); } }
// Use this for initialization void Awake() { var exporter = new GLTFSceneExporter(new[] { transform }, RetrieveTexturePath); var appPath = Application.dataPath; var wwwPath = appPath.Substring(0, appPath.LastIndexOf("Assets")) + "www"; exporter.SaveGLTFandBin(Path.Combine(wwwPath, "TestScene"), "TestScene"); }
private byte[] SaveGLB() { Transform[] transforms = GetAllChildren(hyperverseRoot.transform); GLTFSceneExporter exporter = new GLTFSceneExporter(transforms, RetrieveTexturePath); return(exporter.SaveGLB("hyperverse_loadout")); }
protected void ExportScene(string fileName) { GameObject go = Instantiate(WizardController.instance.instantiatedPatch.gameObject); //GLTFExporter.ExportGameObjToGLTF(WizardController.instance.instantiatedPatch.gameObject, fileName, true, false); CambiarMaterialesaShader(go, "Standard"); var exporter = new GLTFSceneExporter(new[] { go.transform }, new ExportOptions()); exporter.SaveGLB(Path.GetDirectoryName(fileName), Path.GetFileName(fileName)); Destroy(go); }
static void ExportScene() { var scene = SceneManager.GetActiveScene(); var gameObjects = scene.GetRootGameObjects(); var transforms = Array.ConvertAll(gameObjects, gameObject => gameObject.transform); var exporter = new GLTFSceneExporter(transforms); var path = EditorUtility.OpenFolderPanel("glTF Export Path", "", ""); exporter.SaveGLTFandBin(path, scene.name); }
void Start() { var exporter = new GLTFSceneExporter(new[] { transform }); exporter.SaveGLTFandBin("tempDir", "test"); var root = exporter.GetRoot(); var scene = root.GetDefaultScene(); IntegrationTest.Assert(scene.Name == gameObject.name); IntegrationTest.Assert(root.Materials[0].AlphaMode == GLTF.Schema.AlphaMode.BLEND); IntegrationTest.Pass(); }
static void ExportScene() { var scene = SceneManager.GetActiveScene(); var gameObjects = scene.GetRootGameObjects(); var transforms = Array.ConvertAll(gameObjects, gameObject => gameObject.transform); var exportOptions = new ExportOptions { TexturePathRetriever = RetrieveTexturePath }; var exporter = new GLTFSceneExporter(transforms, exportOptions); var path = EditorUtility.OpenFolderPanel("glTF Export Path", "", ""); if (path != "") { exporter.SaveGLTFandBin(path, scene.name); } }
public static void ExportGLTF() { saver = GameObject.FindObjectOfType <CustomLevelSaver>(); var exportOptions = new ExportOptions { TexturePathRetriever = RetrieveTexturePath }; var exporter = new GLTFSceneExporter(saver.GLTFRoot, exportOptions); var path = GetPath(""); if (!string.IsNullOrEmpty(path)) { exporter.SaveGLTFandBin(path, saver.LevelName); } }
/** * 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); }
IEnumerator SaveWebGLTF(float delayTime) { var path = Application.persistentDataPath + "/textile.glb"; if (!string.IsNullOrEmpty(path)) { GameObject go = Instantiate(WizardController.instance.instantiatedPatch.gameObject); CambiarMaterialesaShader(go, "Standard"); var exporter = new GLTFSceneExporter(new[] { go.transform }, new ExportOptions()); exporter.SaveGLB(Path.GetDirectoryName(path), Path.GetFileName(path)); Destroy(go); if (File.Exists(path)) { byte[] byteArray = File.ReadAllBytes(path); DownloadFile(gameObject.name, "OnFileDownload", Path.GetFileName(path), byteArray, byteArray.Length); } } WizardController.instance.ToggleProcessingWindow(); yield return(null); }