private void OnEnable()
 {
     cfg = EditorConfigUtil.LoadConfig <ConfigVO>(CONFIG_NAME);
     if (null == cfg)
     {
         cfg = new ConfigVO();
     }
 }
Exemple #2
0
 /// <summary>
 /// 加载配置
 /// </summary>
 public void LoadConfig()
 {
     Cfg = EditorConfigUtil.LoadConfig <HotResConfigVO>(CONFIG_NAME);
     if (null == Cfg)
     {
         Cfg = new HotResConfigVO();
     }
 }
        private void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.Space();
            if (GUILayout.Button("保存配置"))
            {
                EditorConfigUtil.SaveConfig(cfg, CONFIG_NAME);
                ShowNotification(new GUIContent("保存成功"));
            }

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            cfg.bindingCodeDir = EditorGUILayout.TextField("绑定代码发布目录:", cfg.bindingCodeDir);
            if (GUILayout.Button("选择目录", GUILayout.Width(100)))
            {
                var dir = UnityEditor.EditorUtility.OpenFolderPanel("选择发布目录", "", "");
                if (false == string.IsNullOrEmpty(dir))
                {
                    dir = string.Format("Assets{0}", dir.Replace(Application.dataPath, ""));
                    cfg.bindingCodeDir = dir;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("生成绑定代码", GUILayout.Width(100)))
            {
                var dllFile = UnityEditor.EditorUtility.OpenFilePanel("选择热更DLL", Application.dataPath, "dll");
                if (false == string.IsNullOrEmpty(dllFile))
                {
                    GenerateCLRBindingByAnalysis(dllFile, cfg.bindingCodeDir);
                }

                EditorUtility.DisplayDialog("提示", "成功!", "OK");
                AssetDatabase.Refresh();
            }

            if (GUILayout.Button("清空绑定代码", GUILayout.Width(100)))
            {
                if (FileUtil.DeleteFileOrDirectory(cfg.bindingCodeDir))
                {
                    EditorUtility.DisplayDialog("提示", "成功!", "OK");
                }
                else
                {
                    EditorUtility.DisplayDialog("提示", "失败!", "OK");
                }

                AssetDatabase.Refresh();
            }

            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
Exemple #4
0
 public IOSProjectInitConfig()
 {
     Cfg = EditorConfigUtil.LoadConfig <ConfigVO>(CONFIG_NAME);
     if (null == Cfg)
     {
         Cfg = new ConfigVO();
         SaveCfg();
     }
 }
        private void OnEnable()
        {
            cfg = EditorConfigUtil.LoadConfig <ConfigVO>(CONFIG_NAME);

            if (cfg.data.startupResGroups == null)
            {
                cfg.data.startupResGroups = new string[0];
            }

            if (cfg.data.settingJump == null)
            {
                cfg.data.settingJump = new Dictionary <string, string>();
            }

            if (cfg.data.startupParams == null)
            {
                cfg.data.startupParams = new Dictionary <string, string>();
            }

            _startParamsDic.SetData(cfg.data.startupParams, "Key", "Value");
            _settingJumpDic.SetData(cfg.data.settingJump, "版本号", "跳转地址");
        }
Exemple #6
0
 /// <summary>
 /// 保存配置
 /// </summary>
 public void SaveConfig()
 {
     EditorConfigUtil.SaveConfig(Cfg, CONFIG_NAME);
 }
        private void OnGUI()
        {
            bool isMouseDown = Event.current.type == EventType.MouseDown ? true : false;

            EditorGUILayout.BeginVertical();

            GUIText.LayoutHead("保存setting.json");

            if (GUILayout.Button("保存配置", GUILayout.Width(200)))
            {
                EditorConfigUtil.SaveConfig(cfg, CONFIG_NAME);
                ShowNotification(new GUIContent("保存成功"));
                _startParamsDic.Reload();
                _settingJumpDic.Reload();
            }
            cfg.saveDir = EditorGUILayout.TextField("Setting文件保存目录:", cfg.saveDir);
            EditorGUILayout.Space();


            _pos = GUILayout.BeginScrollView(_pos);

            GUIText.LayoutHead("setting.json编辑");

            GUIText.LayoutSplit("客户端版本");
            EditorGUILayout.BeginHorizontal();
            cfg.data.client.version = EditorGUILayout.TextField("客户端版本号:", cfg.data.client.version, GUILayout.Width(300));
            if (GUILayout.Button("获取当前版本号", GUILayout.Width(100)))
            {
                cfg.data.client.version = Application.version;
            }

            GUILayout.Space(20);
            EditorGUILayout.LabelField("更新方式:", GUILayout.Width(60));

            cfg.data.client.type = EditorGUILayout.Popup(cfg.data.client.type, new string[] { "安装包更新", "网页更新" }, GUILayout.Width(150));

            EditorGUILayout.EndHorizontal();

            cfg.data.client.url = EditorGUILayout.TextField("客户端URl:", cfg.data.client.url);

            //-------------------------------
            EditorGUILayout.LabelField("配置跳转,如果当前客户端版本号有匹配的资源,则使用对应的setting文件");
            cfg.data.settingJump = _settingJumpDic.OnGUI(isMouseDown);

            //--------------------资源配置
            GUIText.LayoutSplit("联网资源");
            cfg.data.netResRoot = EditorGUILayout.TextField("网络资源目录:", cfg.data.netResRoot);

            EditorGUILayout.LabelField("启动资源组列表");
            int groupSize = EditorGUILayout.IntField("数量:", cfg.data.startupResGroups.Length, GUILayout.MaxWidth(200));

            if (groupSize != cfg.data.startupResGroups.Length)
            {
                string[] newArr = new string[groupSize];
                Array.Copy(cfg.data.startupResGroups, 0, newArr, 0, groupSize < cfg.data.startupResGroups.Length ? groupSize : cfg.data.startupResGroups.Length);
                cfg.data.startupResGroups = newArr;
            }

            for (int i = 0; i < cfg.data.startupResGroups.Length; i++)
            {
                cfg.data.startupResGroups[i] = EditorGUILayout.TextField("资源组名称:", cfg.data.startupResGroups[i]);
            }

            //-------------------------------
            GUIText.LayoutSplit("额外参数");
            EditorGUILayout.LabelField("配置文件附带参数");
            cfg.data.startupParams = _startParamsDic.OnGUI(isMouseDown);
            //GUILayoutDictionary(cfg.data.startupParams, "Key", "Value");
            GUILayout.EndScrollView();

            //----------------------------------------------------
            GUILayout.Space(20);
            if (GUILayout.Button("生成[Setting.json]"))
            {
                CreateSettingJsonFile();
                _startParamsDic.Reload();
                _settingJumpDic.Reload();
            }

            EditorGUILayout.EndVertical();
        }