예제 #1
0
        private string GroupToEnumCode(GameEventGroup g)
        {
            string code = "";

            code += "using System.Collections;\r\n";
            code += "using System.Collections.Generic;\r\n";
            if (config.hasNameSpace)
            {
                code += string.Format("namespace {0}\r\n", config.nameSpace);
                code += "{\r\n";
            }
            code += string.Format("public enum {0}\r\n", g.name + "Events");
            code += "{\r\n";
            if (g.events.Count > 0)
            {
                for (int i = 0; i < g.events.Count - 1; i++)
                {
                    code += string.Format("{0}={1},\r\n", g.events[i].name, g.events[i].id);
                }
                code += string.Format("{0}={1}\r\n", g.events[g.events.Count - 1].name, g.events[g.events.Count - 1].id);
            }
            code += "}\r\n";
            if (config.hasNameSpace)
            {
                code += "}\r\n";
            }
            return(code);
        }
예제 #2
0
        private void DrawBasePanel()
        {
            //添加标题
            EditorGUILayout.LabelField(" Base Config", (GUIStyle)"flow navbar back");
            EditorGUI.indentLevel++;
            GUILayout.BeginHorizontal();
            //绘制路径,并添加选择按钮
            config.path    = EditorGUILayout.TextField("Save Path", config.path);
            this.currGroup = this.config.groups[selectedGroupIndex];
            if (GUILayout.Button("", "IN ObjectField", GUILayout.Width(18)))
            {
                config.path = EditorUtility.OpenFolderPanel("Save Event Codes", config.path, "GameEvents");
            }

            GUILayout.EndHorizontal();
            //绘制命名空间字段
            config.hasNameSpace = EditorGUILayout.Toggle("Add NameSpace", config.hasNameSpace);
            if (config.hasNameSpace)
            {
                EditorGUI.indentLevel++;
                config.nameSpace = EditorGUILayout.TextField("NameSpace", config.nameSpace);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Separator();
            EditorGUI.indentLevel--;
        }
예제 #3
0
        private void InitNewConfig()
        {
            Debug.Log("Reset Event Builder Config!");
            this.config = ScriptableObject.CreateInstance <GameEventsConfig>();
            //添加几个默认事件组
            var gameGruop = new GameEventGroup("Game");

            config.groups.Add(gameGruop);
            var uiGroup = new GameEventGroup("UI");

            config.groups.Add(uiGroup);
            this.groupNames = GetGroupNames();
        }
예제 #4
0
        private void DrawGroupPanel()
        {
            //绘制标题
            EditorGUILayout.LabelField(" Event Groups", (GUIStyle)"flow navbar back");
            //如果不是编辑模式
            if (isEditMode == false)
            {
                //开始缩进
                EditorGUI.indentLevel++;
                //组合基本字段
                selectedGroupIndex = EditorGUILayout.Popup("Group", selectedGroupIndex, groupNames);
                currGroup.startNum = EditorGUILayout.IntField("Start Num", currGroup.startNum);
                currGroup.span     = EditorGUILayout.IntField("Span", currGroup.span);
                //开始水平组
                GUILayout.BeginHorizontal();
                //将button居右
                GUILayout.FlexibleSpace();
                //设置按键颜色
                GUI.backgroundColor = new Color(0, 0.9f, 1);
                ;
                if (GUILayout.Button("Edit Group", (GUIStyle)"minibutton", GUILayout.Width(100)))
                {
                    isEditMode = true;
                }

                GUI.backgroundColor = oldColor;
                //结束水平组
                GUILayout.EndHorizontal();
                //结束缩进
                EditorGUI.indentLevel--;
            }
            else
            {
                //开始缩进
                EditorGUI.indentLevel++;
                //开始垂直组
                GUILayout.BeginVertical();
                //开始子水平组
                GUILayout.BeginHorizontal();
                //设置标题文字颜色
                GUI.contentColor = Color.gray;
                //绘制标题
                EditorGUILayout.LabelField("Group TypeID", GUILayout.Width(120));
                EditorGUILayout.LabelField("Count", GUILayout.Width(60));
                //结束子水平组
                GUILayout.EndHorizontal();
                //恢复默认颜色
                GUI.contentColor = oldColor;
                //绘制组合列表
                for (int i = 0; i < config.groups.Count; i++)
                {
                    var g = config.groups[i];
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.TextField(g.name, GUILayout.Width(120));
                    EditorGUILayout.LabelField(g.events.Count.ToString(), GUILayout.Width(60));
                    GUI.backgroundColor = Color.red;
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Del", (GUIStyle)"minibutton", GUILayout.Width(50)))
                    {
                        //如果组合里存在事件,那么删除时显示确定对话框
                        if (config.groups[i].events.Count > 0)
                        {
                            if (EditorUtility.DisplayDialog("删除", "确定删除当前事件组?", "确定", "取消"))
                            {
                                config.groups.RemoveAt(i);
                                isDirty = true;
                            }
                        }
                    }

                    GUI.backgroundColor = oldColor;
                    GUILayout.EndHorizontal();
                }

                GUILayout.EndVertical();
                //开始水平组
                GUILayout.BeginHorizontal();
                newGroupName        = EditorGUILayout.TextField("New Group TypeID", newGroupName);
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Add Group", (GUIStyle)"minibuttonleft", GUILayout.MinWidth(60)))
                {
                    var newGroup = new GameEventGroup(newGroupName);
                    this.config.groups.Add(newGroup);
                    isDirty = true;
                }

                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("Exit Edit", (GUIStyle)"minibuttonright", GUILayout.MinWidth(60)))
                {
                    isEditMode = false;
                }

                GUI.backgroundColor = oldColor;
                GUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
        }