Example #1
0
        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.SaveFolderPanel("glTF Export Path", "", "");

            if (path != "")
            {
                GLTFSceneExporter.SaveFolderPath = path;
                exporter.SaveGLTFandBin(path, scene.name);
            }
        }
Example #2
0
        static void ExportGLBSelected()
        {
            if (!TryGetExportNameAndRootTransformsFromSelection(out var name, out var rootTransforms))
            {
                Debug.LogError("Can't export: selection is empty");
                return;
            }

            var exportOptions = new ExportOptions {
                TexturePathRetriever = RetrieveTexturePath
            };
            var exporter = new GLTFSceneExporter(rootTransforms, exportOptions);

            var path = EditorUtility.SaveFolderPanel("glTF Export Path", GLTFSceneExporter.SaveFolderPath, "");

            if (!string.IsNullOrEmpty(path))
            {
                GLTFSceneExporter.SaveFolderPath = path;
                exporter.SaveGLB(path, name);
            }
        }