From 662b7c84251b1d3c3eb2df9f2f14af5aeb66e9ac Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 8 Mar 2021 12:53:42 +0900 Subject: [PATCH] gltfAssetPostprocessor --- .../Editor/UniGLTF/gltfAssetPostprocessor.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs b/Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs index e12c8b02c..75f127968 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs @@ -1,5 +1,4 @@ -#if false -using System; +using System; using System.IO; using UnityEditor; using UnityEngine; @@ -26,7 +25,6 @@ namespace UniGLTF switch (ext) { case ".gltf": - case ".glb": { var gltfPath = UnityPath.FromUnityPath(path); var prefabPath = gltfPath.Parent.Child(gltfPath.FileNameWithoutExtension + ".prefab"); @@ -50,7 +48,8 @@ namespace UniGLTF var context = new ImporterContext(parser); // Extract textures to assets folder - context.ExtractImages(prefabPath); + var editor = new EditorImporterContext(context); + editor.ExtractImages(prefabPath); ImportDelayed(src, prefabPath, context); } @@ -65,8 +64,9 @@ namespace UniGLTF try { context.Load(); - context.SaveAsAsset(prefabPath); - context.EditorDestroyRoot(); + var editor = new EditorImporterContext(context); + editor.SaveAsAsset(prefabPath); + GameObject.DestroyImmediate(context.Root); } catch (UniGLTFNotSupportedException ex) { @@ -74,16 +74,15 @@ namespace UniGLTF src, ex.Message ); - context.EditorDestroyRootAndAssets(); + context.Dispose(); } catch (Exception ex) { Debug.LogErrorFormat("import error: {0}", src); Debug.LogErrorFormat("{0}", ex); - context.EditorDestroyRootAndAssets(); + context.Dispose(); } }; } } } -#endif \ No newline at end of file