Example #1
0
    void OnGUI()
    {
        GUILayout.Space(20);
        isHotfix = EditorGUILayout.Toggle(isHotfix ? "热更新模式" : "非热更新模式", isHotfix);
        if (isHotfix != AppConst.UpdateMode)
        {
            if (GUILayout.Button("确认切换"))
            {
                ChangHotfix(isHotfix);
                // 代码更改代码要调用刷新
                AssetDatabase.Refresh();
            }
        }
        EditorGUILayout.LabelField("更换当前Sid");
        chooseSID = (SidConfig)EditorGUILayout.EnumPopup(chooseSID.GetDesc(), chooseSID);
        if (chooseSID != AppConst.sidConfig)
        {
            if (GUILayout.Button("确认切换"))
            {
                ChangeChannel(chooseChannelType, chooseSID);
                AssetDatabase.Refresh();
            }
        }
        GUILayout.Space(20);
        EditorGUILayout.LabelField("更换当前渠道 但不替换资源");
        chooseChannelType = (ChannelType)EditorGUILayout.EnumPopup(chooseChannelType.GetChannelString(), chooseChannelType);
        if (chooseChannelType != AppConst.channelType)
        {
            if (GUILayout.Button("确认切换"))
            {
                ChangeChannel(chooseChannelType, chooseSID);
                AssetDatabase.Refresh();
            }
        }
        GUILayout.Space(20);
        EditorGUILayout.LabelField("打包所选渠道");
        using (new EditorGUILayout.HorizontalScope()) {
            for (int i = 0; i < channelTypes.Count; i++)
            {
                GetToggle((ChannelType)i);
            }
        }

        if (GUILayout.Button("打包所选"))
        {
            string allSid = "打包所选\n";
            // 首先判断包类型  然后在判断不同的 sid
            foreach (KeyValuePair <ChannelType, Dictionary <SidConfig, bool> > channelConfigs in sidConfigs)
            {
                willBuildConfigs[channelConfigs.Key] = new List <SidConfig>();
                foreach (KeyValuePair <SidConfig, bool> config in channelConfigs.Value)
                {
                    if (config.Value)
                    {
                        allSid += config.Key.GetDesc() + "\n";
                        willBuildConfigs[channelConfigs.Key].Add(config.Key);
                    }
                }
            }
            Debug.Log(allSid);
        }
        if (willBuildConfigs.Count > 0)
        {
            if (GUILayout.Button("确定打包"))
            {
                Build();
            }
        }
    }