async void LoadModelAsync(string path) { if (!File.Exists(path)) { return; } Debug.LogFormat("{0}", path); var ext = Path.GetExtension(path).ToLower(); switch (ext) { case ".vrm": { var file = File.ReadAllBytes(path); var parser = new GltfParser(); parser.ParseGlb(file); using (var context = new VRMImporterContext(parser)) { await m_texts.UpdateMetaAsync(context); await context.LoadAsync(); context.EnableUpdateWhenOffscreen(); context.ShowMeshes(); context.DisposeOnGameObjectDestroyed(); SetModel(context.Root); } break; } case ".glb": { var file = File.ReadAllBytes(path); var parser = new GltfParser(); parser.ParseGlb(file); var context = new UniGLTF.ImporterContext(parser); context.Load(); context.EnableUpdateWhenOffscreen(); context.ShowMeshes(); context.DisposeOnGameObjectDestroyed(); SetModel(context.Root); break; } case ".gltf": case ".zip": { var parser = new GltfParser(); parser.ParsePath(path); var context = new UniGLTF.ImporterContext(parser); context.Load(); context.EnableUpdateWhenOffscreen(); context.ShowMeshes(); context.DisposeOnGameObjectDestroyed(); SetModel(context.Root); break; } default: Debug.LogWarningFormat("unknown file type: {0}", path); break; } }
void LoadModel(string path) { if (!File.Exists(path)) { return; } Debug.LogFormat("{0}", path); var ext = Path.GetExtension(path).ToLower(); switch (ext) { case ".vrm": { var parser = new UniGLTF.GltfParser(); parser.ParsePath(path); using (var loader = new RuntimeUnityBuilder(parser)) { loader.Load(); loader.ShowMeshes(); loader.EnableUpdateWhenOffscreen(); var destroyer = loader.DisposeOnGameObjectDestroyed(); SetModel(destroyer.gameObject); } break; } case ".glb": { var file = File.ReadAllBytes(path); var parser = new GltfParser(); parser.ParseGlb(file); using (var loader = new UniGLTF.ImporterContext(parser)) { loader.Load(); loader.ShowMeshes(); loader.EnableUpdateWhenOffscreen(); loader.ShowMeshes(); var destroyer = loader.DisposeOnGameObjectDestroyed(); SetModel(destroyer.gameObject); } break; } case ".gltf": case ".zip": { var parser = new GltfParser(); parser.ParsePath(path); using (var loader = new UniGLTF.ImporterContext(parser)) { loader.Load(); loader.ShowMeshes(); loader.EnableUpdateWhenOffscreen(); loader.ShowMeshes(); var destroyer = loader.DisposeOnGameObjectDestroyed(); SetModel(destroyer.gameObject); } break; } default: Debug.LogWarningFormat("unknown file type: {0}", path); break; } }