public void VRMSimpleSceneTest() { var go = CreateSimpelScene(); var context = new VRMImporterContext(); try { // export var gltf = VRMExporter.Export(go); using (var exporter = new gltfExporter(gltf)) { exporter.Prepare(go); exporter.Export(); // import context.ParseJson(gltf.ToJson(), new SimpleStorage()); //Debug.LogFormat("{0}", context.Json); context.Load(); AssertAreEqual(go.transform, context.Root.transform); } } finally { //Debug.LogFormat("Destory, {0}", go.name); GameObject.DestroyImmediate(go); context.Destroy(true); } }
public void UniGLTFSimpleSceneTest() { var go = CreateSimpelScene(); var context = new ImporterContext(); try { // export var gltf = new glTF(); using (var exporter = new gltfExporter(gltf)) { exporter.Prepare(go); exporter.Export(); // import context.ParseJson <glTF>(gltf.ToJson(), new SimpleStorage(new ArraySegment <byte>())); Debug.LogFormat("{0}", context.Json); gltfImporter.Import <glTF>(context); AssertAreEqual(go.transform, context.Root.transform); } } finally { //Debug.LogFormat("Destory, {0}", go.name); GameObject.DestroyImmediate(go); context.Destroy(true); } }
/// <summary> /// Export GLB. /// </summary> public static void ExportGlb() { EditorApplication.isPlaying = false; try { string errorMessage; if (!Validate(out errorMessage)) { Debug.LogAssertion(errorMessage); EditorUtility.DisplayDialog("Error", errorMessage, "OK"); return; } GameObject root = Selection.activeObject as GameObject; string path = EditorUtility.SaveFilePanel(title: "Save File Dialog", directory: "", defaultName: root.name + ".glb", extension: "glb"); if (string.IsNullOrEmpty(path)) { return; } var gltf = new glTF(); using (var exporter = new gltfExporter(gltf)) { exporter.Prepare(root); exporter.Export(); } byte[] bytes = gltf.ToGlbBytes(); File.WriteAllBytes(path, bytes); Debug.LogFormat("Export VGO file.\nGameObject: {0}, output: {1}", root.name, path); if (path.StartsWithUnityAssetPath()) { AssetDatabase.ImportAsset(path.ToUnityRelativePath()); AssetDatabase.Refresh(); } } catch { throw; } }