private static void SwitchMode(string InModeName)
        {
            string defineGroupStr;

            if (string.IsNullOrEmpty(defineGroupStr = EditorPrefs.GetString(ScriptingDefineConfig.DEFINE_GROUP_PREFS_KEY_S, string.Empty)))
            {
                switch (InModeName)
                {
                case ScriptingDefineConfig.EMPTY_MODE_NAME_S:
                    ScriptingDefineTools.SetScriptingDefineSymbols(string.Empty);
                    break;

                case ScriptingDefineConfig.TEST_MODE_NAME_S:
                    ScriptingDefineTools.SetScriptingDefineSymbols(ScriptingDefineConfig.TEST_MACRO_DEFINE_S);
                    break;

                case ScriptingDefineConfig.DEBUG_MODE_NAME_S:
                    ScriptingDefineTools.SetScriptingDefineSymbols(ScriptingDefineConfig.DEBUG_MACRO_DEFINE_S);
                    break;

                case ScriptingDefineConfig.RELEASE_MODE_NAME_S:
                    ScriptingDefineTools.SetScriptingDefineSymbols(string.Empty);
                    break;
                }
            }
            else
            {
                string[] allDefineItem = defineGroupStr.Split(',');
                int      len           = allDefineItem.Length - 1;
                for (int i = 0; i < len; i++)
                {
                    if (allDefineItem[i].StartsWith(InModeName))
                    {
                        string[] defineItems = allDefineItem[i].Split('@')[1].Split('|');
                        len = defineItems.Length;
                        if (len == 0)
                        {
                            ScriptingDefineTools.SetScriptingDefineSymbols(string.Empty);
                        }
                        else
                        {
                            StringBuilder sb = new StringBuilder(len * 16);
                            for (int j = 0; j < len; j++)
                            {
                                sb.Append(defineItems[j].Split('&')[0]).Append(",");
                            }
                            ScriptingDefineTools.SetScriptingDefineSymbols(sb.ToString());
                        }

                        break;
                    }
                }
            }
        }
        private void GetCurrentDefineGroupName()
        {
            currentDefineGroupName = string.Empty;
            string currentDefineSymbols = ScriptingDefineTools.GetScriptingDefineSymbols();

            foreach (KeyValuePair <int, MacroDefineGroup> itor in defineGroup)
            {
                if (itor.Value.GetDefineGroup() == currentDefineSymbols)
                {
                    currentDefineGroupName = itor.Value.GroupName;
                    break;
                }
            }
        }
        private void OnGUI()
        {
            GUILayout.BeginVertical("box");
            GUI.skin.textField.alignment = TextAnchor.LowerCenter;

            #region Scripting Define Group
            if (-1 == editorKey)
            {
                GUILayout.Label(headContent, headStyle);

                int index = 0;
                foreach (KeyValuePair <int, MacroDefineGroup> itor in defineGroup)
                {
                    GUILayout.BeginVertical("Box");
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(index.ToString(), GUILayout.Width(30));
                    if (itor.Value.IsCustomer)
                    {
                        itor.Value.GroupName = GUILayout.TextField(itor.Value.GroupName, GUILayout.Width(300));
                    }
                    else
                    {
                        GUILayout.Label(itor.Value.GroupName, defineLabelStyle, GUILayout.Width(300));
                    }

                    GUI.enabled = currentDefineGroupName != itor.Value.GroupName;
                    if (GUILayout.Button("Select", GUILayout.Width(60)))
                    {
                        if (isGroupEditing)
                        {
                            Dialog.Error("Please finish editing first.");
                        }
                        else
                        {
                            ScriptingDefineTools.SetScriptingDefineSymbols(itor.Value.GetDefineGroup());
                            scriptingDefineWindow.Close();
                        }
                    }

                    GUI.enabled = itor.Value.CanEdit;

                    if (GUILayout.Button("Edit", GUILayout.Width(60)))
                    {
                        if (isGroupEditing)
                        {
                            Dialog.Error("Please finish editing first.");
                        }
                        else
                        {
                            needEditInit = true;
                            editorKey    = itor.Key;
                        }
                    }

                    GUI.enabled = itor.Value.IsCustomer;
                    if (GUILayout.Button("Remove", GUILayout.Width(60)))
                    {
                        if (isGroupEditing)
                        {
                            Dialog.Error("Please finish editing first.");
                        }
                        else
                        {
                            removeKey = itor.Key;
                        }
                    }

                    GUI.enabled = true;
                    GUILayout.EndHorizontal();
                    GUILayout.Space(4);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Preview:", previewStyle, GUILayout.Width(56));
                    GUILayout.BeginHorizontal("box");
                    GUILayout.Label(itor.Value.GetDefineGroup());
                    GUILayout.EndHorizontal();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(4);
                    GUILayout.EndVertical();
                    ++index;
                }

                if (isGroupEditing)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Back", GUILayout.Width(260)))
                    {
                        int count = addedIndexes.Count;
                        for (int i = 0; i < count; i++)
                        {
                            defineGroup.Remove(addedIndexes[i]);
                        }
                        addedIndexes.Clear();
                        isGroupEditing = false;
                    }

                    if (GUILayout.Button("Save", GUILayout.Width(260)))
                    {
                        if (CheckDefineGroup())
                        {
                            Save();
                            addedIndexes.Clear();
                            isGroupEditing = false;
                        }
                    }
                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.BeginVertical();
                    if (GUILayout.Button("Add"))
                    {
                        isGroupEditing = true;
                        int count = defineGroup.Count;
                        defineGroup.Add(count, new MacroDefineGroup("Customize Model"));
                        addedIndexes.Add(count);
                    }

                    GUILayout.Space(280);
                    if (GUILayout.Button("Reset To Default"))
                    {
                        if (EditorUtility.DisplayDialog("Tips",
                                                        "Confirm that you want to delete the locally saved macro definition?", "Ok", "Cancel"))
                        {
                            EditorPrefs.DeleteKey(ScriptingDefineConfig.ALL_DEFINE_PREFS_KEY_S);
                            EditorPrefs.DeleteKey(ScriptingDefineConfig.DEFINE_GROUP_PREFS_KEY_S);

                            Load();
                        }
                    }
                    GUILayout.EndVertical();
                }
            }
            #endregion

            #region Remove Scripting Define Group
            if (-1 != removeKey)
            {
                Debug.LogError(removeKey);
                int count = defineGroup.Count - 1;
                if (removeKey != count)
                {
                    for (int i = removeKey; i < count; i++)
                    {
                        defineGroup[i] = defineGroup[i + 1];
                    }
                }

                defineGroup.Remove(count);
                removeKey = -1;
            }
            #endregion

            #region Editor Scripting Define Group
            if (-1 != editorKey)
            {
                GUILayout.Label(editHeadContent, headStyle);
                GUILayout.BeginVertical("box");

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Scripting Define Group Name:", GUILayout.Width(180));
                GUI.enabled = false;
                GUILayout.TextField(defineGroup[editorKey].GroupName, GUILayout.Width(360));
                GUI.enabled = true;
                GUILayout.EndHorizontal();

                List <MacroDefine> selectedDefines = defineGroup[editorKey].DefineGroup;
                int selectedCount = selectedDefines.Count;

                int count = allDefine.Count;

                for (int i = 0; i < count; i++)
                {
                    GUILayout.BeginHorizontal("box");
                    GUILayout.Label(i.ToString(), GUILayout.Width(30));
                    allDefine[i].Define = GUILayout.TextField(allDefine[i].Define, GUILayout.Width(300));

                    if (needEditInit)
                    {
                        allDefine[i].IsSelected = false;
                        if (0 != selectedCount)
                        {
                            for (int j = 0; j < selectedCount; j++)
                            {
                                if (allDefine[i].Define == selectedDefines[j].Define)
                                {
                                    allDefine[i].IsSelected = true;
                                    break;
                                }
                            }
                        }
                    }

                    GUI.enabled             = allDefine[i].IsCustomer;
                    allDefine[i].IsSelected = GUILayout.Toggle(allDefine[i].IsSelected, "Select", GUILayout.Width(60));

                    GUI.enabled = allDefine[i].IsCustomer;
                    if (GUILayout.Button("Remove", GUILayout.Width(60)))
                    {
                        bool          canRemove     = true;
                        string        currentDefine = allDefine[i].Define;
                        StringBuilder sb            = new StringBuilder(defineGroup.Count * 16);
                        foreach (KeyValuePair <int, MacroDefineGroup> itor in defineGroup)
                        {
                            foreach (MacroDefine macroDefine in itor.Value.DefineGroup)
                            {
                                if (macroDefine.Define == currentDefine)
                                {
                                    sb.Append("<").Append(itor.Value.GroupName).Append(">");
                                    canRemove = false;
                                    break;
                                }
                            }
                        }

                        if (canRemove)
                        {
                            allDefine.RemoveAt(i);
                        }
                        else
                        {
                            Dialog.Error("The select to be deleted is being used by \n" + sb + "\nso it cannot be deleted.");
                        }
                    }
                    GUI.enabled = true;

                    GUI.enabled = i != 0;
                    if (GUILayout.Button("^", GUILayout.Width(30)))
                    {
                        MacroDefine temp = allDefine[i];
                        allDefine[i]     = allDefine[i - 1];
                        allDefine[i - 1] = temp;
                    }

                    GUI.enabled = i != count - 1;
                    if (GUILayout.Button("v", GUILayout.Width(30)))
                    {
                        MacroDefine temp = allDefine[i];
                        allDefine[i]     = allDefine[i + 1];
                        allDefine[i + 1] = temp;
                    }

                    GUI.enabled = true;
                    GUILayout.EndHorizontal();
                }

                if (isDefineEditing)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Back", GUILayout.Width(260)))
                    {
                        allDefine.RemoveAt(allDefine.Count - 1);
                        isDefineEditing = false;
                    }

                    if (GUILayout.Button("Save", GUILayout.Width(260)))
                    {
                        if (CheckAllDefine())
                        {
                            isDefineEditing = false;
                            Save();
                            if (currentDefineGroupName == defineGroup[editorKey].GroupName)
                            {
                                GetCurrentDefineGroupName();
                            }
                        }
                    }
                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Back", GUILayout.Width(174)))
                    {
                        if (CheckAllDefine())
                        {
                            isDefineEditing = false;
                            editorKey       = -1;
                        }
                    }

                    if (GUILayout.Button("Save", GUILayout.Width(174)))
                    {
                        if (CheckAllDefine())
                        {
                            SaveDefineGroup(editorKey);
                            Save();
                            isDefineEditing = false;
                            editorKey       = -1;
                        }
                    }

                    if (GUILayout.Button("Add", GUILayout.Width(174)))
                    {
                        isDefineEditing = true;
                        allDefine.Add(new MacroDefine(string.Empty, true));
                    }
                    GUILayout.EndHorizontal();
                }

                needEditInit = false;
            }

            #endregion


            GUILayout.EndVertical();
        }