protected override void OnBegin() { base.OnBegin(); var tempFile = "Assets/" + mRequestPackageData.Name + ".unitypackage"; Debug.Log(mRequestPackageData.DownloadUrl + ">>>>>>:"); EditorUtility.DisplayProgressBar("插件更新", "插件下载中 ...", 0.1f); var progressListener = new ScheduledNotifier <float>(); ObservableWWW.GetAndGetBytes(mRequestPackageData.DownloadUrl, null, progressListener) .Subscribe(bytes => { File.WriteAllBytes(tempFile, bytes); EditorUtility.ClearProgressBar(); AssetDatabase.ImportPackage(tempFile, true); File.Delete(tempFile); mRequestPackageData.SaveVersionFile(); AssetDatabase.Refresh(); InstalledPackageVersions.Reload(); }); progressListener.Subscribe(OnProgressChanged); }
protected override void OnBegin() { base.OnBegin(); var tempFile = "Assets/" + mRequestPackageData.Name + ".unitypackage"; Debug.Log(mRequestPackageData.DownloadUrl + ">>>>>>:"); EditorUtility.DisplayProgressBar("插件更新", "插件下载中 ...", 0.1f); var progressListener = new ScheduledNotifier <float>(); ObservableWWW.GetAndGetBytes(mRequestPackageData.DownloadUrl, null, progressListener) .Subscribe(bytes => { File.WriteAllBytes(tempFile, bytes); EditorUtility.ClearProgressBar(); AssetDatabase.ImportPackage(tempFile, false); File.Delete(tempFile); mRequestPackageData.SaveVersionFile(); AssetDatabase.Refresh(); EditorUtility.DisplayDialog(mRequestPackageData.Name, "插件下载成功", "OK"); InstalledPackageVersions.Reload(); // EditorApplication.ExecuteMenuItem(FrameworkMenuItems.Preferences); }, e => { EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog(mRequestPackageData.Name, "插件安装失败,请联系 [email protected] 或者加入 QQ 群:623597263" + e.ToString() + ";", "OK"); }); progressListener.Subscribe(OnProgressChanged); }