private void ApplyDefine() { m_Defines.Clear(); for (int iGroup = 0; iGroup < m_DefineGroups.Count; iGroup++) { DefineGroup iterGroup = m_DefineGroups[iGroup]; for (int iDefine = 0; iDefine < iterGroup.Defines.Count; iDefine++) { DefineItem iterDefine = iterGroup.Defines[iDefine]; if (iterDefine.Enable) { m_Defines.Add(iterDefine.Define); } } } string[] otherDefines = m_OtherDefines.Split(new char[] { '\n' } , StringSplitOptions.RemoveEmptyEntries); for (int iDefine = 0; iDefine < otherDefines.Length; iDefine++) { m_Defines.Add(otherDefines[iDefine]); } ScriptingDefineSymbolsUtility.SetScriptingDefineSymbols(m_Defines.ToList()); }
private void RefreshDefine() { ScriptingDefineSymbolsUtility.s_TemporarySymbols.Clear(); ScriptingDefineSymbolsUtility.GetScriptingDefineSymbols(ScriptingDefineSymbolsUtility.s_TemporarySymbols); m_Defines = new HashSet <string>(ScriptingDefineSymbolsUtility.s_TemporarySymbols); HashSet <string> otherDefines = new HashSet <string>(m_Defines); for (int iGroup = 0; iGroup < m_DefineGroups.Count; iGroup++) { DefineGroup iterGroup = m_DefineGroups[iGroup]; for (int iDefine = 0; iDefine < iterGroup.Defines.Count; iDefine++) { DefineItem iterDefine = iterGroup.Defines[iDefine]; iterDefine.Enable = m_Defines.Contains(iterDefine.Define); otherDefines.Remove(iterDefine.Define); } } m_OtherDefines = string.Join("\n", otherDefines); }
public override void OnGUI(string searchContext) { base.OnGUI(searchContext); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("应用")) { ApplyDefine(); RefreshDefine(); } if (GUILayout.Button("刷新")) { RefreshDefine(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); m_DefineGroupFoldout.Set(EditorGUILayout.Foldout(m_DefineGroupFoldout, "组")); EditorGUILayout.EndHorizontal(); if (m_DefineGroupFoldout) { EditorGUI.indentLevel++; for (int iGroup = 0; iGroup < m_DefineGroups.Count; iGroup++) { DefineGroup iterGroup = m_DefineGroups[iGroup]; EditorGUILayout.BeginHorizontal(); iterGroup.Foldout.Set(EditorGUILayout.Foldout(iterGroup.Foldout, iterGroup.Name)); if (GUILayout.Button("开启所有", GUILayout.Width(96))) { for (int iDefine = 0; iDefine < iterGroup.Defines.Count; iDefine++) { iterGroup.Defines[iDefine].Enable = true; } } if (GUILayout.Button("关闭所有", GUILayout.Width(96))) { for (int iDefine = 0; iDefine < iterGroup.Defines.Count; iDefine++) { iterGroup.Defines[iDefine].Enable = false; } } EditorGUILayout.EndHorizontal(); if (!iterGroup.Foldout) { continue; } EditorGUI.indentLevel++; for (int iDefine = 0; iDefine < iterGroup.Defines.Count; iDefine++) { DefineItem iterDefine = iterGroup.Defines[iDefine]; iterDefine.Enable = EditorGUILayout.ToggleLeft(EditorGUIUtility.TrTextContent(iterDefine.Name , iterDefine.Tooltip) , iterDefine.Enable); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); m_OtherFoldout.Set(EditorGUILayout.Foldout(m_OtherFoldout, "其他")); EditorGUILayout.EndHorizontal(); if (m_OtherFoldout) { EditorGUI.indentLevel++; m_OtherDefines = EditorGUILayout.TextArea(m_OtherDefines); EditorGUI.indentLevel--; } }