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 void ImportVci(UnityPath path) { if (!path.IsUnderAssetsFolder) { throw new Exception(); } var importer = new VCIImporter(); importer.ParseGlb(File.ReadAllBytes(path.FullPath)); var prefabPath = path.Parent.Child(path.FileNameWithoutExtension + ".prefab"); // save texture assets ! importer.ExtranctImages(prefabPath); importer.ExtractAudio(prefabPath); importer.ExtractEffekseer(prefabPath); EditorApplication.delayCall += () => { // // after textures imported // importer.Load(); importer.SetupCorutine().CoroutinetoEnd(); importer.SetupPhysics(); importer.SetupAttachable(); importer.SetupEffekseer(); importer.SetupText(); importer.SetupSpringBone(); importer.SaveAsAsset(prefabPath); importer.EditorDestroyRoot(); }; }
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); }