private void OnShow() { ObservableWWW.Get(URL_GITHUB_API_LATEST_RELEASE).Subscribe(response => { var latestedVersionInfo = FrameworkVersionInfo.ParseLatest(response); latestedVersionInfo.Assets.ForEach(asset => { Log.I(asset.Name); if (asset.Name.StartsWith("QFramework")) { var version = asset.Name.Replace("QFramework_v", string.Empty).Replace(".unitypackage", string.Empty); var versionChars = version.Split('.'); int versionCode = 0; versionChars.ForEach(versionChar => { versionCode *= 100; versionCode += versionChar.ToInt(); }); Log.I(versionCode); // 版本比较 ObservableWWW.GetAndGetBytes(asset.BrowserDownloadUrl).Subscribe(bytes => { File.WriteAllBytes(Application.dataPath + "/" + asset.Name, bytes); AssetDatabase.ImportPackage(Application.dataPath + "/" + asset.Name, true); }); } }); }, e => { Log.E(e); }); }
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); }
public void LoadScript(Action loadDone) { //初始化资源加载 string dllPath = ""; if (dllPath != "") { //反射 if (ILRuntimeScriptSetting.Default.HotfixRunMode == HotfixCodeRunMode.Reflection) { //反射模式只支持Editor PC Android if (File.Exists(dllPath)) //支持File操作 或者存在 { LoadDll(dllPath); loadDone.InvokeGracefully(); } else { //不支持file操作 或者不存在,继续尝试 var path = dllPath; if (Application.isEditor) { path = "file://" + path; } ObservableWWW.GetAndGetBytes(path).Subscribe(bytes => { LoadDll(bytes); loadDone.InvokeGracefully(); }, e => { Debug.LogError("DLL加载失败:" + e); }); } } //ILR else { //ILRuntime基于文件流,所以不支持file操作的,得拷贝到支持File操作的目录 //这里情况比较复杂,Mobile上基本认为Persistent才支持File操作, //可寻址目录也只有 StreamingAsset var firstPath = ILRuntimeScriptSetting.DllFilePersistentFullPath; var secondPath = ILRuntimeScriptSetting.DllFileStreamingFullPath; if (!File.Exists(dllPath)) //仅当指定的路径不存在(或者不支持File操作)时,再进行可寻址 { dllPath = firstPath; if (!File.Exists(firstPath)) { //验证 可寻址目录2 var source = secondPath; var copyto = firstPath; Debug.Log("复制到第一路径:" + source); ObservableWWW.GetAndGetBytes(source) .Subscribe(bytes => { copyto.CreateDirIfNotExists4FilePath(); File.WriteAllBytes(copyto, bytes); //解释执行模式 ILRuntimeScriptSetting.Default.HotfixRunMode = HotfixCodeRunMode.ILRuntime; LoadDll(copyto); loadDone.InvokeGracefully(); }, e => { Debug.LogError("可寻址目录不包括DLL:" + source); }); return; } } //解释执行模式 LoadDll(dllPath); loadDone.InvokeGracefully(); } } else { // pc 模式 ILRuntimeScriptSetting.Default.HotfixRunMode = HotfixCodeRunMode.Editor; LoadDll(""); loadDone.InvokeGracefully(); } }