public void OnGUI() { mScrollPos = GUILayout.BeginScrollView(mScrollPos, true, true, GUILayout.Width(560), GUILayout.Height(300)); for (int i = mReadme.items.Count - 1; i >= 0; i--) { ReadmeItem item = mReadme.items [i]; GUILayout.BeginHorizontal(EditorStyles.helpBox); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("version: " + item.version, mTitleStyle, GUILayout.Width(130)); GUILayout.Label("" + item.date, mTitleStyle, GUILayout.Width(130)); GUILayout.Label("author: " + item.author); if (GUILayout.Button("download")) { string fileUrl = PTPluginConfigData.GetServerUrl() + "/" + string.Format("{0}/{1}_v{2}.unitypackage", serverPlugin.type, serverPlugin.name, item.version); Application.OpenURL(fileUrl); } GUILayout.EndHorizontal(); GUILayout.Label(item.content); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }
public static List <PluginCategory> GetLocalCategories(PTPluginConfigData resConfig) { List <PluginCategory> localCategories = new List <PluginCategory>(); string[] files = System.IO.Directory.GetFiles(Application.dataPath, "ptplugin.txt", System.IO.SearchOption.AllDirectories); foreach (var config in resConfig.configDatas) { PluginCategory pluginCategory = new PluginCategory(); pluginCategory.type = config.type; foreach (var fileInfo in files) { string content = File.ReadAllText(Path.GetFullPath(fileInfo)); PluginInfo pluginInfo = JsonUtility.FromJson <PluginInfo> (content); if (pluginInfo.type == config.type) { pluginCategory.plugins.Add(pluginInfo); } } localCategories.Add(pluginCategory); } return(localCategories); }
public static List <ConfigData> SetDefaultValues(PTPluginConfigData pluginConfig) { PluginCategory[] mPluginTypes = PTPluginUtil.GetServerAllTypes(pluginConfig.serverUrl); List <ConfigData> mActiveConfigs = new List <ConfigData>(); mActiveConfigs.AddRange(pluginConfig.configDatas); List <ConfigData> mConfigDatas = new List <ConfigData>(); foreach (var type in mPluginTypes) { ConfigData config = new ConfigData(); config.type = type.type; ConfigData activeConfig = mActiveConfigs.FirstOrDefault(s => s.type == type.type); config.enableCheck = activeConfig == null ? false : activeConfig.enableCheck; config.enableNew = activeConfig == null ? false : activeConfig.enableNew; config.active = activeConfig == null ? false : activeConfig.active; if (type.type == "ptgame") { config.active = true; } config.name = type.name; mConfigDatas.Add(config); } return(mConfigDatas); }
public void OnEnable() { InitStyles(); resConfig = PTPluginConfigData.GetPluginConfig(); remoteCategories = PTPluginUtil.GetRemoteCategories(resConfig); localCategories = PTPluginUtil.GetLocalCategories(resConfig); curLocalCategory = PTPluginUtil.GetLocalCategoryByType(localCategories, resConfig.configDatas.FirstOrDefault(s => s.active).type); }
public static PTPluginConfigData GetPluginConfig() { string configFile = Path.Combine(DIR_CONFIGFILE, NAME_CONFIGFILE); if (!File.Exists(configFile)) { CreateDefaultPluginConfig(); } PTPluginConfigData resConfig = AssetDatabase.LoadAssetAtPath <PTPluginConfigData> (configFile) as PTPluginConfigData; return(resConfig); }
static PTPluginCheck() { if (!EditorApplication.isPlayingOrWillChangePlaymode) { PTPluginCheck pluginCheck = new PTPluginCheck(); pluginCheck.mCheckStatus = CheckStatus.WAIT; pluginCheck.mNextCheckTime = EditorApplication.timeSinceStartup; pluginCheck.mPluginConfig = PTPluginConfigData.GetPluginConfig(); pluginCheck.mCheckInterval = pluginCheck.mPluginConfig.checkInterval; EditorApplication.update = pluginCheck.CustomUpdate; } }
public static string[] GetTypes() { PTPluginConfigData resConfig = GetPluginConfig(); string[] types = new string[resConfig.configDatas.Count]; for (int i = 0; i < types.Length; i++) { types [i] = resConfig.configDatas [i].type; } return(types); }
private static void CreateDefaultPluginConfig() { PTPluginConfigData nameInfoObj = ScriptableObject.CreateInstance <PTPluginConfigData>(); nameInfoObj.configDatas = new List <ConfigData>(); nameInfoObj.checkInterval = 60; nameInfoObj.serverUrl = "http://10.1.223.240:5010/ptplugin"; nameInfoObj.configDatas = SetDefaultValues(nameInfoObj); if (!Directory.Exists(DIR_CONFIGFILE)) { Directory.CreateDirectory(DIR_CONFIGFILE); } UnityEditor.AssetDatabase.CreateAsset(nameInfoObj, Path.Combine(DIR_CONFIGFILE, NAME_CONFIGFILE)); AssetDatabase.Refresh(); }
public static List <PluginCategory> GetRemoteCategories(PTPluginConfigData resConfig) { if (Application.internetReachability == NetworkReachability.NotReachable) { return(null); } WWW www = new WWW(resConfig.serverUrl + "/getplugins"); while (!www.isDone) { } if (www.error != null) { return(null); } string json = www.text; PTPluginInfos pluginInfos = JsonUtility.FromJson <PTPluginInfos> (json); List <PluginCategory> categories = new List <PluginCategory>(); foreach (var config in resConfig.configDatas) { if (config.active) { PluginCategory category = new PluginCategory(); category.url = resConfig.serverUrl; category.type = config.type; category.plugins = pluginInfos.plugins.Where(s => s.type == config.type).ToList(); categories.Add(category); } } return(categories); }
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 DrawInit() { if (mHasRemotePlugin) { GUILayout.BeginHorizontal(); GUILayout.Label("本地版本号", GUILayout.Width(70)); GUILayout.Label(mLocalVersionText, GUILayout.Width(100)); GUIStyle newVersionStyle = new GUIStyle(); newVersionStyle.alignment = TextAnchor.LowerLeft; newVersionStyle.normal.textColor = new Color(1, 1, 0); GUILayout.Label("远端版本号", newVersionStyle, GUILayout.Width(70)); GUILayout.Label(mPluginInfo.version, newVersionStyle, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("插件类型", GUILayout.Width(70)); mPluginTypeIndex = EditorGUILayout.Popup(mPluginTypeIndex, mPluginTypes, GUILayout.Width(100)); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("插件类型", GUILayout.Width(70)); mPluginTypeIndex = EditorGUILayout.Popup(mPluginTypeIndex, mPluginTypes, GUILayout.Width(100)); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label("发布版本号", GUILayout.Width(70)); mVersionText = GUILayout.TextField(mVersionText, GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.Label("发布说明:", GUILayout.Width(150)); mReadmeText = GUILayout.TextArea(mReadmeText, GUILayout.Width(250), GUILayout.Height(300)); if (GUILayout.Button("发布", GUILayout.Width(150))) { if (mReadmeText.Length < 2) { ShowErrorMsg("请输入版本修改说明"); return; } if (!IsVersionValide(mVersionText)) { ShowErrorMsg("请输入正确的版本号"); return; } mPluginInfo.version = mVersionText; mPluginInfo.readme.AddReadme(new ReadmeItem(mVersionText, mReadmeText, SystemInfo.deviceName, DateTime.Now.ToString("g"))); mPluginInfo.type = mPluginTypes[mPluginTypeIndex]; mPluginInfo.url = mPluginDir; mUploadUrl = PTPluginConfigData.GetServerUrl(); if (mUploadUrl == null) { ShowErrorMsg(string.Format("请到 {0} 确认 类型 {0} 已配置", "Assets/PTUGame/ptpluginconfig", mPluginInfo.type)); return; } string t = JsonUtility.ToJson(mPluginInfo, true); File.WriteAllText(mPluginDir + "/ptplugin.txt", t); AssetDatabase.Refresh(); GotoPacking(); } }
public static string GetServerUrl() { PTPluginConfigData resConfig = GetPluginConfig(); return(resConfig.serverUrl); }
public void OnEnable() { mPlugincConfig = PTPluginConfigData.GetPluginConfig(); mConfigDatas = PTPluginConfigData.SetDefaultValues(mPlugincConfig); }