Exemple #1
0
        protected override void OnLogCreated(ValidationLog validationLog)
        {
            validationLog.scenePath = SceneManager.GetActiveScene().path;
            validationLog.source    = LogSource.Scene;

            base.OnLogCreated(validationLog);
        }
        private static void AppendLog(ValidationLog validationLog, FileOutputFormat outputFormat)
        {
            switch (outputFormat)
            {
            case FileOutputFormat.Html:
                string classStyle;
                if (!_validatorToHtmlStyle.TryGetValue(validationLog.validatorName, out classStyle))
                {
                    classStyle = string.Empty;
                }

                _stringBuilder.AppendLine(string.Format(HtmlTableRowFormat,
                                                        classStyle,
                                                        validationLog.validatorName,
                                                        validationLog.logType,
                                                        validationLog.source,
                                                        validationLog.message,
                                                        validationLog.scenePath,
                                                        validationLog.objectPath));
                break;

            case FileOutputFormat.Csv:
                _stringBuilder.AppendLine(string.Format(CsvRowFormat,
                                                        validationLog.validatorName,
                                                        validationLog.logType,
                                                        validationLog.source,
                                                        validationLog.message,
                                                        validationLog.scenePath,
                                                        validationLog.objectPath));
                break;

            case FileOutputFormat.Text:
                _stringBuilder.AppendLine(string.Format(PlainTextRowFormat,
                                                        validationLog.validatorName,
                                                        validationLog.logType,
                                                        validationLog.source,
                                                        validationLog.message,
                                                        validationLog.scenePath,
                                                        validationLog.objectPath));
                break;

            default:
                var msg = string.Format(EditorConstants.OutputFormatIsInvalid, outputFormat);
                throw new ArgumentOutOfRangeException(msg);
            }
        }
Exemple #3
0
        /// <summary>
        /// Attempts to ping an <see cref="UnityEngine.Object"/> instance in the current scene or project window
        /// based on the passed <see cref="ValidationLog"/> <paramref name="log"/>.
        /// </summary>
        /// <param name="log"></param>
        internal static void TryPingObject(ValidationLog log)
        {
            UnityEngine.Object obj = null;
            if (log.source == LogSource.Scene)
            {
                obj = GameObject.Find(log.objectPath);
            }
            else if (log.source == LogSource.Project)
            {
                obj = AssetDatabase.LoadAssetAtPath(log.objectPath, typeof(UnityEngine.Object));
            }

            if (obj != null)
            {
                EditorGUIUtility.PingObject(obj);
            }
            else
            {
                Debug.LogWarningFormat(EditorConstants.CouldNotPingObjectWarning, log.objectPath);
            }
        }
Exemple #4
0
        /// <summary>
        /// Draws the appropriate row background for a <see cref="ValidationLog"/> <paramref name="log"/>.
        /// </summary>
        /// <param name="bgRect"></param>
        /// <param name="log"></param>
        private static void DrawRowBackground(Rect bgRect, ValidationLog log)
        {
            if (Event.current.type == EventType.Repaint)
            {
                var originalColor = GUI.color;
                GUI.color = GraphicsTools.GetLogHeaderColor(log);
                var rect = bgRect;
                rect.height = 25f;
                GraphicsTools.LogRowHeaderBackground.Draw(rect, false, false, false, false);
                GUI.color = originalColor;

                if (log == null)
                {
                    return;
                }

                rect.y     += rect.height;
                rect.height = bgRect.height - rect.height;
                GraphicsTools.LogRowBodyBackground.Draw(rect, false, false, false, false);
            }
        }
Exemple #5
0
        /// <summary>
        /// Returns the appropriate <see cref="Color"/> based on the passed <see cref="ValidationLog"/>
        /// <paramref name="log"/>'s <see cref="LogType"/>. If null, the <see cref="LogType.Info"/> header
        /// color is returned.
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public static Color GetLogHeaderColor(ValidationLog log)
        {
            Color color;
            var   logType = log == null ? LogType.Info : log.logType;

            switch (logType)
            {
            case LogType.Warning:
                color = Color.yellow;
                break;

            case LogType.Error:
                color = Color.red;
                break;

            default:
                color = _grayColor;
                break;
            }

            return(color);
        }
Exemple #6
0
        /// <summary>
        /// Returns the appropriate <see cref="GUIStyle"/> for the passed <see cref="ValidationLog"/>
        /// <paramref name="validationLog"/> based in its <see cref="LogType"/>. If null, the
        /// <see cref="LogType.Info"/> header style is returned.
        /// </summary>
        /// <param name="validationLog"></param>
        /// <returns></returns>
        public static GUIStyle GetLogHeaderStyle(ValidationLog validationLog)
        {
            GUIStyle style;

            var logType = validationLog == null ? LogType.Info : validationLog.logType;

            switch (logType)
            {
            case LogType.Warning:
                style = EditorGUIUtility.isProSkin ? EditorStyles.whiteBoldLabel : EditorStyles.boldLabel;
                break;

            case LogType.Error:
                style = EditorGUIUtility.isProSkin ? EditorStyles.boldLabel : EditorStyles.whiteBoldLabel;
                break;

            default:
                style = EditorGUIUtility.isProSkin ? EditorStyles.boldLabel : EditorStyles.whiteBoldLabel;
                break;
            }

            return(style);
        }
        protected override void OnLogCreated(ValidationLog validationLog)
        {
            validationLog.source = LogSource.Project;

            base.OnLogCreated(validationLog);
        }
 protected void DispatchVLogEvent(ValidationLog validationLog)
 {
     LogCreated?.Invoke(validationLog);
 }
Exemple #9
0
 /// <summary>
 /// Constructor that accepts a <see cref="ValidationLog"/> and a custom <see cref="string"/>
 /// <paramref name="displayName"/>.
 /// </summary>
 /// <param name="log"></param>
 /// <param name="id"></param>
 /// <param name="depth"></param>
 /// <param name="displayName"></param>
 public ValidationLogTreeViewItem(ValidationLog log, int id, int depth, string displayName)
     : base(id, depth, displayName)
 {
     Log = log;
 }
Exemple #10
0
 /// <summary>
 /// Constructor that accepts a <see cref="ValidationLog"/> and sets an empty display name.
 /// </summary>
 /// <param name="log"></param>
 /// <param name="id"></param>
 /// <param name="depth"></param>
 public ValidationLogTreeViewItem(ValidationLog log, int id, int depth)
     : base(id, depth, string.Empty)
 {
     Log = log;
 }
Exemple #11
0
 /// <summary>
 /// Invoked when a validator has emitted a <see cref="ValidationLog"/> via an event, adds
 /// it to the cache if there is one.
 /// </summary>
 /// <param name="validationLog"></param>
 protected virtual void OnLogCreated(ValidationLog validationLog)
 {
     _logCache.OnLogCreated(validationLog);
 }