Пример #1
0
    void AddUpdateInfo(ref XGameUpdate.AppUpdateInfo rv, XGameUpdate.resInfo updateInfo)
    {
        XGameUpdate.resInfo value = rv.resInfo.Find((XGameUpdate.resInfo findValue) => {
            return(findValue.type == updateInfo.type);
        });

        if (value != null)
        {
            rv.resInfo.Remove(value);
        }

        rv.resInfo.Add(updateInfo);
    }
Пример #2
0
    void OnGUI()
    {
        m_ScrollViewPos = EditorGUILayout.BeginScrollView(m_ScrollViewPos, false, false, GUILayout.Height(Screen.height - 30));

        GUILayout.Label("当前游戏程序版本号:" + UnityEditor.PlayerSettings.bundleVersion);

        if (GUILayout.Button("选择update_config文件路径"))
        {
            m_jsonFilePath = EditorUtility.OpenFilePanel("选择update_config文件路径", "", "json");
            LoadVUFile(m_jsonFilePath);
        }

        GUILayout.Label("");

        m_drawAppFolder = EditorGUILayout.Foldout(m_drawAppFolder, new GUIContent("App版本信息"));
        if (m_drawAppFolder)
        {
            DrawAppInfo();
        }

        m_drawPackUrl = EditorGUILayout.Foldout(m_drawPackUrl, new GUIContent("安装包信息"));
        if (m_drawPackUrl)
        {
            DrawPackageUrl();
        }

        var s = new GUIStyle();

        s.richText = true;
        var text = "";

        GUILayout.Label("");
        var delGameVerIndex = new List <int>();

        for (int i = 0; m_versionInfo != null && m_versionInfo.dynamicUpdateInfo != null && i < m_versionInfo.dynamicUpdateInfo.Count; ++i)
        {
            text = "<color=green>删除程序版本</color>";
            if (GUILayout.Button(text, s))
            {
                delGameVerIndex.Add(i);
            }
            var vui = m_versionInfo.dynamicUpdateInfo[i];
            m_folders[i].versionFolder = EditorGUILayout.Foldout(m_folders[i].versionFolder, "游戏程序版本" + vui.baseVersion + " 更新信息");
            vui.baseVersion            = EditorGUILayout.TextField("程序版本:", vui.baseVersion);
            if (m_folders[i].versionFolder)
            {
                var delPlatformIndex = new List <int>();
                for (int j = 0; j < vui.resVersionInfo.Count; ++j)
                {
                    text = "<color=yellow>  删除资源版本</color>";
                    if (GUILayout.Button(text, s))
                    {
                        delPlatformIndex.Add(j);
                    }

                    var pui = vui.resVersionInfo[j];
                    int platform;
                    pui.resVersion  = EditorGUILayout.TextField("  兼容资源版本:", pui.resVersion);
                    pui.forceUpdate = bool.Parse(EditorGUILayout.TextField("    可否跳过资源版本更新:", pui.forceUpdate.ToString()));
                    if (int.TryParse(EditorGUILayout.TextField("    平台:", pui.basePlatform.ToString()), out platform))
                    {
                        pui.basePlatform = platform;
                    }
                    if (int.TryParse(EditorGUILayout.TextField("    测试服务器ID:", pui.testSvrId.ToString()), out platform))
                    {
                        pui.testSvrId = platform;
                    }
                    var delResVersionIndex = new List <int>();

                    Action <string, string> ressCB = (string buttonName, string ressName) => {
                        EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb, GUILayout.ExpandWidth(true));
                        if (GUILayout.Button(buttonName, GUILayout.Width(120)))
                        {
                            XGameUpdate.UpdateFileInfo fi = null;
                            switch (ressName)
                            {
                            case "Table":
                                fi = GenTableData();
                                break;

                            case "AssetBundles":
                                //fi = GenAssetsBundle(pui.resVersion);
                                fi = GenAssetsBundle_New();
                                break;

                            case "Lua":
                                fi = GenLua();
                                break;

                            case "DLL":
                                fi = GenDLL();
                                break;

                            case "MapFile":
                                fi = GenMapFile();
                                break;

                            case "Audio":
                                fi = GenAudio();
                                break;
                            }
                            if (fi != null)
                            {
                                AddUpdateInfo(ref pui, new XGameUpdate.resInfo(fi));
                            }
                        }
                        XGameUpdate.resInfo ressInfo = pui.resInfo.Find((XGameUpdate.resInfo findvalue) => {
                            return(findvalue.type == ressName);
                        });

                        if (ressInfo != null)
                        {
                            ressInfo.md5 = EditorGUILayout.TextField("", ressInfo.md5);
                            if (string.IsNullOrEmpty(ressInfo.md5))
                            {
                                pui.resInfo.Remove(ressInfo);
                            }
                        }
                        else
                        {
                            EditorGUILayout.TextField("", "");
                        }
                        EditorGUILayout.EndHorizontal();
                    };

                    ressCB("选择TableData文件夹", "Table");
                    ressCB("选择AssetBundles文件夹", "AssetBundles");
                    ressCB("选择DLL文件夹", "DLL");
                    ressCB("选择Lua文件夹", "Lua");
                    ressCB("选择MapFile文件夹", "MapFile");
                    ressCB("选择Audio文件夹", "Audio");
                }
                for (int j = 0; j < delPlatformIndex.Count; ++j)
                {
                    vui.resVersionInfo.RemoveAt(delPlatformIndex[j]);
                    ResetFolders();
                }
            }
            text = "<color=yellow>添加资源版本</color>";
            if (GUILayout.Button(text, s))
            {
                var pui = new XGameUpdate.AppUpdateInfo();
                vui.resVersionInfo.Add(pui);
                ResetFolders();
            }
        }
        text = "<color=green>添加程序版本</color>";
        if (GUILayout.Button(text, s))
        {
            var vui = new XGameUpdate.UpdatePackageInfo();
            m_versionInfo.dynamicUpdateInfo.Add(vui);
            ResetFolders();
        }
        for (int i = 0; i < delGameVerIndex.Count; ++i)
        {
            m_versionInfo.dynamicUpdateInfo.RemoveAt(delGameVerIndex[i]);
            ResetFolders();
        }
        GUILayout.Label("");
        if (GUILayout.Button("保存"))
        {
            Save();
        }

        EditorGUILayout.EndScrollView();
    }