コード例 #1
0
 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();
         }
     };
 }
コード例 #2
0
ファイル: UniGLTFTests.cs プロジェクト: notargs/VCI
        public void UniGLTFSimpleSceneTest()
        {
            var go      = CreateSimpleScene();
            var context = new ImporterContext();

            try
            {
                // export
                var gltf = new glTF();

                string json = null;
                using (var exporter = new gltfExporter(gltf))
                {
                    exporter.Prepare(go);
                    exporter.Export();

                    // remove empty buffer
                    gltf.buffers.Clear();

                    json = gltf.ToJson();
                }

                // import
                context.ParseJson(json, new SimpleStorage(new ArraySegment <byte>()));
                //Debug.LogFormat("{0}", context.Json);
                context.Load();

                AssertAreEqual(go.transform, context.Root.transform);
            }
            finally
            {
                //Debug.LogFormat("Destroy, {0}", go.name);
                GameObject.DestroyImmediate(go);
                context.EditorDestroyRootAndAssets();
            }
        }