Пример #1
0
        /// <summary>
        ///     Draws the log entry for the given game event.
        /// </summary>
        /// <param name="gameEvent"></param>
        /// <param name="instanceID"></param>
        private void DrawLogEntry(GameEvent gameEvent, int instanceID)
        {
            Vector2 scrollPosition;

            if (!_eventEntriesScrollPosition.TryGetValue(instanceID, out scrollPosition))
            {
                scrollPosition = Vector2.zero;
                _eventEntriesScrollPosition.Add(instanceID, scrollPosition);
            }

            Color originalGUIColor = GUI.backgroundColor;

            GUI.backgroundColor = SOFlowEditorSettings.TertiaryLayerColour;

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, true, false, GUI.skin.horizontalScrollbar,
                                                             GUIStyle.none, SOFlowStyles.HelpBox,
                                                             GUILayout.Height(EditorGUIUtility.singleLineHeight * 7f),
                                                             GUILayout.Width(position.width - _entryWidth - 40f));

            GUI.backgroundColor = originalGUIColor;

            EditorGUILayout.BeginHorizontal();

            for (int i = gameEvent.EventStack.Count - 1; i >= 0; i--)
            {
                int skippedEntries = 0;

                SOFlowEditorUtilities.DrawSecondaryLayer(() =>
                {
                    EditorGUILayout.LabelField($"Log Entry {i + 1}",
                                               SOFlowStyles.CenterTextHelpBox);

                    EditorGUILayout.BeginHorizontal();

                    for (int j = 0,
                         condition = gameEvent.EventStack[i].Listener.Count;
                         j < condition;
                         j++)
                    {
                        string searchQuery;

                        _eventEntrySearchQuery.TryGetValue(instanceID,
                                                           out searchQuery);

                        GameEventLog log      = gameEvent.EventStack[i];
                        GameObject gameObject = log.Listener[j].GetGameObject();

                        if (string.IsNullOrEmpty(searchQuery) ||
                            gameObject == null ||
                            gameObject.name.ToLower()
                            .Contains(searchQuery.ToLower()))
                        {
                            SOFlowEditorUtilities
                            .DrawColourLayer(log.IsError[j] ? SOFlowEditorSettings.DeclineContextColour : SOFlowEditorSettings.AcceptContextColour,
                                             () =>
                                             DrawEventLog(log, j));
                        }
                        else
                        {
                            skippedEntries++;
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                },
                                                         GUILayout.MaxWidth(_entryWidth *
                                                                            (gameEvent.EventStack[i].Listener.Count -
                                                                             skippedEntries)));
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndScrollView();

            _eventEntriesScrollPosition[instanceID] = scrollPosition;
        }
Пример #2
0
        /// <summary>
        ///     Draws the event stack.
        /// </summary>
        private void DrawEventStack()
        {
            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("Event Stack", SOFlowStyles.BoldCenterLabel);
            GUILayout.FlexibleSpace();

            EditorGUILayout.LabelField($"Size: {_target.EventStack.Count}", SOFlowStyles.WordWrappedMiniLabel);

            EditorGUILayout.EndHorizontal();

            SOFlowEditorUtilities.DrawScrollViewColourLayer(SOFlowEditorSettings.TertiaryLayerColour, ref _logScrollPosition,
                                                            () =>
            {
                foreach (GameEventLog log in _target.EventStack)
                {
                    SOFlowEditorUtilities.DrawSecondaryLayer(() =>
                    {
                        for (int i = 0,
                             errorIndex
                                 = 0,
                             condition
                                 = log
                                   .Listener
                                   .Count;
                             i <
                             condition;
                             i++)
                        {
                            SOFlowEditorUtilities
                            .DrawHorizontalColourLayer(log.IsError[i] ? SOFlowEditorSettings.DeclineContextColour : SOFlowEditorSettings.SecondaryLayerColour,
                                                       () =>
                            {
                                EditorGUILayout
                                .LabelField($"[{log.LogTime:T}] {log.Listener[i].GetObjectType().Name}");

                                EditorGUILayout
                                .ObjectField(log
                                             .Listener
                                             [i]
                                             .GetGameObject(),
                                             typeof
                                             (GameObject
                                             ),
                                             true);

                                if
                                (log
                                 .IsError
                                 [i]
                                )
                                {
                                    if
                                    (SOFlowEditorUtilities
                                     .DrawColourButton("Log",
                                                       SOFlowEditorSettings
                                                       .TertiaryLayerColour)
                                    )
                                    {
                                        _currentErrorMessage
                                            = $"{log.ErrorMessages[errorIndex]}\n\n{log.StackTraces[errorIndex]}";

                                        _currentErrorData
                                            = log
                                              .ErrorData
                                              [errorIndex];
                                    }
                                }
                            });

                            if (log
                                .IsError
                                [i]
                                )
                            {
                                errorIndex
                                ++;
                            }
                        }
                    });
                }
            }, GUILayout.MaxHeight(_scrollHeight));
        }
Пример #3
0
 /// <summary>
 ///     Draws the comparison fields.
 /// </summary>
 private void DrawComparisonFields()
 {
     SOFlowEditorUtilities.DrawSecondaryLayer(DrawTypes);
 }