示例#1
0
        private static Material ExportThenImport(Material src)
        {
            //
            // export
            //
            GameObject cube     = GameObject.CreatePrimitive(PrimitiveType.Cube);
            var        renderer = cube.GetComponent <Renderer>();

            renderer.sharedMaterial = src;
            var gltf     = new glTF();
            var exporter = new VCIExporter(gltf);

            exporter.Prepare(cube);
            exporter.Export();
            var bytes = gltf.ToGlbBytes();

            //
            // importer
            //
            var importer = new VCIImporter();

            importer.ParseGlb(bytes);
            importer.Load();
            var dst = importer.GetMaterial(0);

            return(dst);
        }
        private static Material ExportThenImport(Material src)
        {
            //
            // export
            //
            var gltf     = new glTF();
            var exporter = new VCIExporter(gltf);

            exporter.Materials = new System.Collections.Generic.List <Material> {
                src
            };
            exporter.Export();
            var bytes = gltf.ToGlbBytes();

            //
            // importer
            //
            var importer = new VCIImporter();

            importer.ParseGlb(bytes);
            importer.Load();
            var dst = importer.GetMaterial(0);

            return(dst);
        }