private void ShowReadMe(PluginInfo serverPlugin, PluginReadme readme) { PTPluginReadmeWin.Init(serverPlugin, readme); }
void OnEnable() { UnityEngine.Object[] selectObject = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets); if (selectObject == null || selectObject.Length > 1) { return; } mPluginDir = AssetDatabase.GetAssetPath(selectObject[0]); string dirName = Path.GetFileName(mPluginDir).ToLower(); PTPluginConfigData resConfig = PTPluginConfigData.GetPluginConfig(); PTPluginUtil.PTPluginInfos remoteInfos = PTPluginUtil.GetPluginWithName(resConfig.serverUrl, dirName); PluginInfo localPluginInfo = GetLocalPluginInfo(); if (remoteInfos != null && remoteInfos.plugins.Count > 0) { foreach (var item in remoteInfos.plugins) { if (localPluginInfo != null && item.type == localPluginInfo.type) { mRemotePluginInfo = item; break; } } if (mRemotePluginInfo == null) { mRemotePluginInfo = remoteInfos.plugins[0]; } } // mRemotePluginInfo = PTPluginUtil.GetPluginWithName(resConfig.serverUrl,dirName); mPluginTypes = PTPluginUtil.GetServerAllTypeNames(resConfig.serverUrl); if (mRemotePluginInfo != null) { mHasRemotePlugin = true; mPluginInfo = mRemotePluginInfo; mVersionText = mPluginInfo.version; mReadmeText = mPluginInfo.readme.GetItem(mPluginInfo.version).content; mPluginTypeIndex = Array.IndexOf(mPluginTypes, mPluginInfo.type); if (localPluginInfo != null) { mLocalVersionText = localPluginInfo.version; Version v1 = new Version(localPluginInfo.version); Version v2 = new Version(mPluginInfo.version); if (v1.CompareTo(v2) != 0) { EditorUtility.DisplayDialog("warning", "本地版本跟服务器版本不一致,请确认", "确定"); } } } else { mHasRemotePlugin = false; mPluginInfo = new PluginInfo(); } mPluginInfo.name = Path.GetFileName(mPluginDir).ToLower(); EditorApplication.update += Update; }
private void DrawWithServer(PluginCategory localCategory, PluginCategory serverCategory) { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Plugin", titleStyle, GUILayout.Width(150)); GUILayout.Label("Server", titleStyle, GUILayout.Width(100)); GUILayout.Label("Local", titleStyle, GUILayout.Width(100)); GUILayout.Label("Action", titleStyle, GUILayout.Width(100)); GUILayout.Label("Readme", titleStyle, GUILayout.Width(100)); GUILayout.EndHorizontal(); foreach (var serverPlugin in serverCategory.plugins) { GUILayout.BeginHorizontal(EditorStyles.helpBox); GUILayout.Label(serverPlugin.name, defaultStype, GUILayout.Width(150)); GUILayout.Label(serverPlugin.version, titleStyle, GUILayout.Width(100)); PluginInfo localPlugin = localCategory.GetPluginInfoByName(serverPlugin.name); if (localPlugin != null) { if (PTPluginUtil.HasNewVersion(serverPlugin.version, localPlugin.version)) { GUILayout.Label(localPlugin.version, newVersionStyle, GUILayout.Width(100)); if (GUILayout.Button("Update", GUILayout.Width(90))) { if (EditorUtility.DisplayDialog("UpdatePlugin", "是否移除本地旧版本?", "是", "否")) { if (!string.IsNullOrEmpty(localPlugin.url)) { Directory.Delete(localPlugin.url, true); AssetDatabase.Refresh(); } } PTPluginUpdate.UpdatePlugin(serverCategory.url + "/" + serverPlugin.url, serverPlugin.name + "_v" + serverPlugin.version); } } else { GUILayout.Label(localPlugin.version, installedStyle, GUILayout.Width(100)); if (GUILayout.Button("Import", GUILayout.Width(90))) { if (EditorUtility.DisplayDialog("UpdatePlugin", "是否移除本地旧版本?", "是", "否")) { if (!string.IsNullOrEmpty(localPlugin.url)) { Directory.Delete(localPlugin.url, true); AssetDatabase.Refresh(); } } PTPluginUpdate.UpdatePlugin(serverCategory.url + "/" + serverPlugin.url, serverPlugin.name + "_v" + serverPlugin.version); } } } else { GUILayout.Label(" ", newVersionStyle, GUILayout.Width(100)); if (GUILayout.Button("Import", GUILayout.Width(90))) { PTPluginUpdate.UpdatePlugin(serverCategory.url + "/" + serverPlugin.url, serverPlugin.name + "_v" + serverPlugin.version); } } if (GUILayout.Button("Readme", GUILayout.Width(90))) { ShowReadMe(serverPlugin, serverPlugin.readme); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
private void ProcessCompare() { mConfigIndex++; if (mConfigIndex >= mPluginConfig.configDatas.Count) { mConfigIndex = 0; } ConfigData configData = mPluginConfig.configDatas[mConfigIndex]; if (!configData.enableCheck) { GoToWait(); return; } Debug.Log("***** update res check ******"); Debug.Log("check plugin :" + configData.type + " configIndex:" + mConfigIndex + " count:" + mPluginConfig.configDatas.Count); List <PluginCategory> categories = PTPluginUtil.GetRemoteCategories(mPluginConfig); PluginCategory remoteCategory = PTPluginUtil.GetRemoteCategoryByType(categories, configData.type); if (remoteCategory == null) { GoToWait(); return; } List <PluginCategory> localCategories = PTPluginUtil.GetLocalCategories(mPluginConfig); PluginCategory localCategory = PTPluginUtil.GetLocalCategoryByType(localCategories, configData.type); if (localCategory != null) { foreach (var remotePlugin in remoteCategory.plugins) { PluginInfo localPlugin = localCategory.GetPluginInfoByName(remotePlugin.name); if (localPlugin == null) { if (configData.enableNew) { ShowNewVersionDialog(configData.type); break; } } else { bool remoteHasNewVersion = PTPluginUtil.HasNewVersion(remotePlugin.version, localPlugin.version); if (remoteHasNewVersion) { ShowNewVersionDialog(configData.type); break; } } } } else { ShowNewVersionDialog(configData.type); } GoToWait(); }