Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }