public static VRMMetaObject ReadMeta(this VRMImporterContext context, bool createThumbnail = false) { var task = context.ReadMetaAsync(default(UniGLTF.ImmediateCaller), createThumbnail); task.Wait(); return(task.Result); }
async void OnLoadClicked() { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", ".vrm"); #elif UNITY_EDITOR var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif if (string.IsNullOrEmpty(path)) { return; } var bytes = File.ReadAllBytes(path); // なんらかの方法でByte列を得た // GLB形式でJSONを取得しParseします var parser = new GltfParser(); parser.ParseGlb(bytes); using (var context = new VRMImporterContext(parser)) { // metaを取得(todo: thumbnailテクスチャのロード) var meta = await context.ReadMetaAsync(); Debug.LogFormat("meta: title:{0}", meta.Title); // ParseしたJSONをシーンオブジェクトに変換していく await context.LoadAsync(); OnLoaded(context); } }
async void OnLoadClicked() { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", ".vrm"); #elif UNITY_EDITOR var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif if (string.IsNullOrEmpty(path)) { return; } // GLB形式でJSONを取得しParseします var data = new GlbFileParser(path).Parse(); // VRM extension を parse します var vrm = new VRMData(data); using (var context = new VRMImporterContext(vrm)) { // metaを取得(todo: thumbnailテクスチャのロード) var meta = await context.ReadMetaAsync(); Debug.LogFormat("meta: title:{0}", meta.Title); // ParseしたJSONをシーンオブジェクトに変換していく var loaded = await context.LoadAsync(); loaded.ShowMeshes(); loaded.EnableUpdateWhenOffscreen(); OnLoaded(loaded.gameObject); } }
public async Task UpdateMetaAsync(VRMImporterContext context) { var meta = await context.ReadMetaAsync(new TaskCaller(), true); m_textModelTitle.text = meta.Title; m_textModelVersion.text = meta.Version; m_textModelAuthor.text = meta.Author; m_textModelContact.text = meta.ContactInformation; m_textModelReference.text = meta.Reference; m_textPermissionAllowed.text = meta.AllowedUser.ToString(); m_textPermissionViolent.text = meta.ViolentUssage.ToString(); m_textPermissionSexual.text = meta.SexualUssage.ToString(); m_textPermissionCommercial.text = meta.CommercialUssage.ToString(); m_textPermissionOther.text = meta.OtherPermissionUrl; m_textDistributionLicense.text = meta.LicenseType.ToString(); m_textDistributionOther.text = meta.OtherLicenseUrl; m_thumbnail.texture = meta.Thumbnail; }
async void LoadVRMClicked() { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", ".vrm"); #elif UNITY_EDITOR var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif if (string.IsNullOrEmpty(path)) { return; } // GLB形式でJSONを取得しParseします var data = new GlbFileParser(path).Parse(); // var data = new GlbBinaryParser(anyBinary).Parse(); using (var context = new VRMImporterContext(data)) { // metaを取得(todo: thumbnailテクスチャのロード) var meta = await context.ReadMetaAsync(); Debug.LogFormat("meta: title:{0}", meta.Title); // ParseしたJSONをシーンオブジェクトに変換していく var loaded = default(RuntimeGltfInstance); if (m_loadAsync) { loaded = await context.LoadAsync(); } else { loaded = context.Load(); } OnLoaded(loaded); } }