Esempio n. 1
0
        public void CalcDraw(bool reset, FastList <CullList> _cullLists)
        {
            if (reset)
            {
                startHeight = 0;
                cullList.cullItems.Clear();
            }

            cullLists.Clear();

            for (int i = 0; i < _cullLists.Count; i++)
            {
                CullList cullList = _cullLists.items[i];
                if (reset)
                {
                    cullList.currentCalcCullItem = 0;
                }
                if (cullList.currentCalcCullItem < cullList.cullItems.Count)
                {
                    cullLists.Add(cullList);
                }
            }

            // Debug.Log("CullLists " + cullLists.Count + " reset " + reset);

            while (cullLists.Count > 0)
            {
                int idMax         = int.MaxValue;
                int nextItemIndex = -1;

                for (int i = 0; i < cullLists.Count; i++)
                {
                    CullList cullList = cullLists.items[i];

                    int id = cullList.cullItems.items[cullList.currentCalcCullItem].id;
                    if (id < idMax)
                    {
                        idMax         = id;
                        nextItemIndex = i;
                    }
                }

                if (!cullLists.items[nextItemIndex].Draw(cullList, ref startHeight))
                {
                    cullLists.RemoveAt(nextItemIndex);
                }
            }

            if (reset && cullList.cullItems.Count > 0 && (cullList.cullItems.items[cullList.cullItems.Count - 1]).isHeader)
            {
                cullList.cullItems.RemoveLast();
            }
        }
Esempio n. 2
0
        void Awake()
        {
#if !UNITY_EDITOR
            isDebugBuild = Debug.isDebugBuild;
#endif
            ResetStatic();
            consoleWindow = windowData.consoleWindow;

            logs      = new CullList[6];
            cullGroup = new CullGroup(logSize * logs.Length);

            for (int i = 0; i < logs.Length; i++)
            {
                logs[i] = new CullList(logSize);
            }

            SetActive(showConsoleOnStart);

            inputCommand = string.Empty;

            logs[commandLogs].cullItems.Add(new LogEntry("-------------------------------------------------------------------------------", Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry(Helper.GetApplicationInfo(), Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry("-------------------------------------------------------------------------------", Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry(string.Empty, Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry("Type '?' to list all commands", Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry(string.Empty, Color.white, titleFontSize, FontStyle.Bold));

            GUIChangeBool.ApplyUpdates();

            Register(this);

            CalcDraw(true);

#if UNITY_EDITOR
            if (testOnlyFreeConsoleCommands)
            {
                accessLevel = AccessLevel.Free;
            }
            else
            {
                accessLevel = AccessLevel.Admin;
            }
#else
            if (adminModeInBuild == AccessMode.Enabled)
            {
                accessLevel = AccessLevel.Admin;
            }
#endif
        }
Esempio n. 3
0
        public bool Draw(CullList currentCullItems, ref double startHeight)
        {
            CullItem cullItem = cullItems.items[currentCalcCullItem++];

            DrawResult drawResult = cullItem.DoDraw();

            if (drawResult != DrawResult.DontDraw)
            {
                SortedFastList <CullItem> cullItems = currentCullItems.cullItems;

                cullItem.Draw(ref startHeight);
                cullItems.Add(cullItem);

                if (drawResult == DrawResult.DrawHeaderAndRemoveLastHeader)
                {
                    double height = cullItems.items[lastAddedIndex].endHeight - cullItems.items[lastAddedIndex].startHeight;;
                    startHeight -= height;
                    cullItems.RemoveAt(lastAddedIndex);

                    for (int i = lastAddedIndex; i < cullItems.Count; i++)
                    {
                        cullItems.items[i].startHeight -= height;
                        cullItems.items[i].endHeight   -= height;
                    }
                }

                if (drawResult == DrawResult.DrawHeader || drawResult == DrawResult.DrawHeaderAndRemoveLastHeader)
                {
                    lastAddedIndex = cullItems.Count - 1;
                }
                currentCullItems.lastDrawResult = drawResult;
            }

            if (currentCalcCullItem >= cullItems.Count)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 4
0
 public CullGroup(int capacity)
 {
     cullList = new CullList(capacity);
 }
Esempio n. 5
0
        void DrawLogs(Event currentEvent, Rect window)
        {
            GUISkin skin = windowData.skin;

            rectScroll = new Rect(4, 54, window.width - (drawLogsScrollBar ? 22 : 10), window.height - 80);

            bool showStack = _showStack.Value;

            CullList logList = cullGroup.cullList;

            if (currentEvent.type == EventType.Layout)
            {
                scrollViewEndHeight = 0;
                if (logList.cullItems.Count > 0)
                {
                    scrollViewEndHeight = logList.cullItems.items[logList.cullItems.Count - 1].endHeight;
                }
                double endHeightBegin = scrollViewEndHeight - rectScroll.height;

                if (scrollViewEndHeight > rectScroll.height)
                {
                    if (showLastLog.Value)
                    {
                        scrollView.y = endHeightBegin;
                    }
                }

                scrollViewHeights = new Double2(scrollView.y, scrollView.y + rectScroll.height);
                logList.Cull(scrollViewHeights);
            }

            if (logList.cullItems.Count == 0)
            {
                return;
            }

            GUILayout.BeginArea(rectScroll);
            double startSpace = logList.cullItems.items[logList.startIndex].startHeight - scrollView.y;

            GUILayout.Space((float)startSpace);

            for (int i = logList.startIndex; i <= logList.endIndex; i++)
            {
                var log = (LogEntry)logList.cullItems.items[i];

                skin.label.fontSize  = log.fontSize;
                skin.label.fontStyle = log.fontStyle;

                if (log.entryType == EntryType.Frame)
                {
                    GUILayout.Space(20);
                }

                GUILayout.BeginHorizontal();
                if (log.entryType == EntryType.Unity)
                {
                    if (log.logType == LogType.Warning)
                    {
                        GUI.color = Color.yellow;
                    }
                    else if (log.logType == LogType.Error)
                    {
                        GUI.color = Color.red;
                    }
                    else if (log.logType == LogType.Exception)
                    {
                        GUI.color = Color.magenta;
                    }
                    else if (log.logType == LogType.Log)
                    {
                        GUI.color = Color.white;
                    }
                }
                else
                {
                    GUI.color = log.color;
                }

                if (log.entryType == EntryType.Unity || log.entryType == EntryType.Console || log.entryType == EntryType.Command || log.entryType == EntryType.CommandResult)
                {
                    GUILayout.Space(30);
                }

                if (log.threadString != null)
                {
                    float width = GUI.skin.label.CalcSize(Helper.GetGUIContent(log.logString)).x;
                    GUILayout.Label(log.logString, GUILayout.Width(width));
                }
                else
                {
                    GUILayout.Label(log.logString); // + " " + log.tStamp);// + " " + (log.endHeight - log.startHeight));
                }
                // GUILayout.Label((GUILayoutUtility.GetLastRect().y + scrollView.y).ToString(), GUILayout.Width(70));

                if (log.entryType == EntryType.Unity || log.entryType == EntryType.Console || log.entryType == EntryType.Command)
                {
                    Rect rect = GUILayoutUtility.GetLastRect();
                    rect.x -= 12;
                    rect.y += log.fontSize / 2;
                    if (log.entryType == EntryType.Unity)
                    {
                        rect.width  = 4;
                        rect.height = 4;
                        GUI.DrawTexture(rect, windowData.texDot);
                    }
                    else
                    {
                        rect.y     -= 2;
                        rect.width  = 8;
                        rect.height = 8;
                        GUI.DrawTexture(rect, windowData.texArrow);
                    }
                }
                if (log.threadString != null)
                {
                    GUI.skin.label.fontStyle = FontStyle.Italic;
                    GUILayout.Label(log.threadString);
                    GUI.skin.label.fontStyle = FontStyle.Normal;
                }
                GUILayout.EndHorizontal();

                if (showStack && log.stackLines != null)
                {
                    skin.label.fontSize = stackFontSize;
                    GUILayout.Space(-3);
                    GUI.color = GUI.color * 0.825f;

                    for (int j = 0; j < log.stackLines.Length; j++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(30);
                        GUILayout.Label(log.stackLines[j]);
                        GUILayout.EndHorizontal();
                    }
                }

                GUI.color = Color.white;
                if (!logs[commandLogs].show.RealValue && !showUnityLogs.RealValue)
                {
                    showUnityLogs.Value = true;
                }
            }

            skin.label.fontSize  = 12;
            skin.label.fontStyle = FontStyle.Normal;
            GUILayout.EndArea();

            // GUILayout.Label("scrollHeight " + rectScroll.height + " posY " + scrollView.y + " height " + height + " => " + (scrollView.y + rectScroll.height));
        }