async Task LoadModelAsync(string path) { Debug.LogFormat("{0}", path); var model = await Task.Run(() => { if (!File.Exists(path)) { return(null); } var vrmModel = VrmLoader.CreateVrmModel(path); return(vrmModel); }); if (model == null) { return; } m_texts.UpdateMeta(model); // UniVRM-0.XXのコンポーネントを構築する var importer = new UniVRM10.RuntimeUnityBuilder(); var assets = importer.ToUnityAsset(model); UniVRM10.ComponentBuilder.Build10(model, importer, assets); SetModel(assets.Root); }
private ModelAsset ToUnity(byte[] bytes) { // Vrm => Model var model = VrmLoader.CreateVrmModel(bytes, new FileInfo("tmp.vrm")); model.RemoveSecondary(); return(ToUnity(model)); }
IEnumerator LoadModelAsync(string path) { Debug.LogFormat("{0}", path); var task = Task.Run(() => { if (!File.Exists(path)) { return(null); } var vrmModel = VrmLoader.CreateVrmModel(path); return(vrmModel); }); while (!task.IsCompleted) { // 終了待ち yield return(null); } var model = task.Result; if (model == null) { yield break; } m_texts.UpdateMeta(model); // UniVRM-0.XXのコンポーネントを構築する var assets = new ModelAsset(); // build async yield return(AsyncUnityBuilder.ToUnityAssetAsync(model, assets)); UniVRM10.ComponentBuilder.Build10(model, assets); SetModel(assets); }
private void LoadModel(string path) { try { // If BVH trigger is still on if (_bvhLoadingTrigger == true) { LoadMotion(_bvhPathSaved); } if (!File.Exists(path)) { return; } Debug.LogFormat("{0}", path); var vrmModel = VrmLoader.CreateVrmModel(path); // Call License Update function _licensePanel.LicenseUpdatefunc(vrmModel); // UniVRM-0.XXのコンポーネントを構築する var assets = new ModelAsset(); // build UnityBuilder.ToUnityAsset(vrmModel, assets); UniVRM10.ComponentBuilder.Build10(vrmModel, assets); // Set up Model SetModel(assets); } catch (Exception e) { _errorMessagePanel.SetMessage(MultipleLanguageSupport.VrmLoadErrorMessage + "\nError message: " + e.Message); throw; } }