Пример #1
0
        protected static List <DefineSymbol> FindDefineSymbols(string regex)
        {
            // first search for symbols that match the given expressions and
            // are on lines that have #*, then filter out the #*
            string path = Application.dataPath;
            string arg  = string.Format("-Roh --include=\"*.cs\" \"\\#.*[[:<:]]{0}[[:>:]]\" .", regex);

            string[] args = { arg };
            string   error;
            string   output = RunCommand("grep", path, out error, args);

            string[] matches = output.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries).
                               OrderBy(a => a).
                               Distinct().
                               ToArray();

            arg = string.Format("-ohw \"{0}\"", regex);
            string filteredOutput = RunCommand("grep", path, matches, out error, new string[] { arg });

            List <string> symbolNames = filteredOutput.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries).
                                        OrderBy(a => a).
                                        Distinct().
                                        ToList();

            List <DefineSymbol> symbols = new List <DefineSymbol>();

            foreach (var symbolName in symbolNames)
            {
                bool         isDefined = DebugEditorUtils.IsSymbolDefined(symbolName);
                DefineSymbol symbol    = new DefineSymbol(symbolName, isDefined);
                symbols.Add(symbol);
            }

            return(symbols);
        }
Пример #2
0
        virtual protected void DrawSymbol(DefineSymbol symbol)
        {
            GUILayoutOption[] columnOpts =
            {
                GUILayout.Width(25),
                GUILayout.Width(300),
                GUILayout.Width(50),
            };

            GUILayout.BeginHorizontal();

            symbol.IsSelected = GUILayout.Toggle(symbol.IsSelected, GUIContent.none, columnOpts[0]);

            GUILayout.Label(symbol.Name, this.LabelStyle, columnOpts[1]);

            Color  color       = symbol.IsEnabled ? Color.green : Color.red;
            string enabledText = string.Format("<color=#{0}>{1}</color>", SagoDebug.Debug.ColorToHex(color), symbol.IsEnabled);

            EditorGUI.BeginChangeCheck();
            symbol.IsEnabled = GUILayout.Toggle(symbol.IsEnabled, enabledText, this.ButtonStyle, columnOpts[2]);
            if (EditorGUI.EndChangeCheck())
            {
                DebugEditorUtils.UpdateDefineSymbol(symbol.Name, symbol.IsEnabled);
            }

            GUILayout.EndHorizontal();
        }
Пример #3
0
        override protected void FindDefineSymbols()
        {
            base.FindDefineSymbols();

            const string baseName = "SAGO_DEBUG";

            if (this.DefineSymbols.FirstOrDefault(ds => ds.Name == baseName) == null)
            {
                bool         isDefined = DebugEditorUtils.IsSymbolDefined(baseName);
                DefineSymbol symbol    = new DefineSymbol(baseName, isDefined);
                this.DefineSymbols.Insert(0, symbol);
            }
        }
Пример #4
0
        virtual protected void DrawBatchButtons()
        {
            GUILayout.BeginHorizontal();

            IEnumerable <DefineSymbol> selected = this.DefineSymbols.Where(s => s.IsSelected);

            EditorGUI.BeginDisabledGroup(selected.Count() == 0);

            EditorGUI.BeginDisabledGroup(selected.All(e => e.IsEnabled));
            if (GUILayout.Button("Enable Selected"))
            {
                DebugEditorUtils.UpdateDefineSymbols(
                    this.DefineSymbols.Where(s => s.IsSelected).Select(n => n.Name).ToArray(),
                    null);
            }
            EditorGUI.EndDisabledGroup();              // Nothing to enable

            if (GUILayout.Button("Toggle Selected"))
            {
                DebugEditorUtils.UpdateDefineSymbols(
                    this.DefineSymbols.Where(s => s.IsSelected && !s.IsEnabled).Select(n => n.Name).ToArray(),
                    this.DefineSymbols.Where(s => s.IsSelected && s.IsEnabled).Select(n => n.Name).ToArray());
            }

            EditorGUI.BeginDisabledGroup(selected.All(e => !e.IsEnabled));
            if (GUILayout.Button("Disabled Selected"))
            {
                DebugEditorUtils.UpdateDefineSymbols(
                    null,
                    this.DefineSymbols.Where(s => s.IsSelected).Select(n => n.Name).ToArray());
            }
            EditorGUI.EndDisabledGroup();              // Nothing to disable

            EditorGUI.EndDisabledGroup();              // Nothing selected

            GUILayout.EndHorizontal();
        }