static void ImportDelayed(string src, UnityPath prefabPath, ImporterContext context) { EditorApplication.delayCall += () => { // // After textures imported(To ensure TextureImporter be accessible). // try { context.Load(); context.SaveAsAsset(prefabPath); context.EditorDestroyRoot(); } catch (UniGLTFNotSupportedException ex) { Debug.LogWarningFormat("{0}: {1}", src, ex.Message ); context.EditorDestroyRootAndAssets(); } catch (Exception ex) { Debug.LogErrorFormat("import error: {0}", src); Debug.LogErrorFormat("{0}", ex); context.EditorDestroyRootAndAssets(); } }; }
public void UniGLTFSimpleSceneTest() { var go = CreateSimpleScene(); ImporterContext context = default; try { // export var gltf = new glTF(); string json = null; using (var exporter = new gltfExporter(gltf)) { exporter.Prepare(go); exporter.Export(MeshExportSettings.Default); // remove empty buffer gltf.buffers.Clear(); json = gltf.ToJson(); } // parse var parser = new GltfParser(); parser.ParseJson(json, new SimpleStorage(new ArraySegment <byte>())); // import context = new ImporterContext(parser); context.Load(); AssertAreEqual(go.transform, context.Root.transform); } finally { //Debug.LogFormat("Destroy, {0}", go.name); GameObject.DestroyImmediate(go); if (context != null) { context.EditorDestroyRootAndAssets(); } } }