Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

Severity

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

The degree of failure associated with a log message.

Indicates whether a log message is an error or warning.

Additional resources: LogMessage.

using UnityEditor;
using UnityEditor.ShaderApiReflection;
using UnityEngine;

// This example adds a menu item which re-logs any reflection errors reported by shader includes
// selected in the project view.
public class ShaderIncludeReflectionErrorPrinter
{
    [MenuItem("Examples/ShaderIncludeReflectionErrorPrinter")]
    static void PrintErrors()
    {
        // Visit each selected object
        foreach (Object selectedObject in Selection.objects)
        {
            // Check if the object is a ShaderInclude
            if (selectedObject is ShaderInclude includeObject)
            {
                // Re-log each reflection message
                foreach (LogMessage message in includeObject.Reflection.LogMessages)
                {
                    string formattedMessage =
                        $"{message.ErrorCode} {message.MessageSeverity} at {message.Location.FilePath}"
                        + $" (line {message.Location.Line}): {message.Text}";
                    if (message.MessageSeverity == LogMessage.Severity.Error)
                        Debug.LogError(formattedMessage);
                    else
                        Debug.LogWarning(formattedMessage);
                }
            }
        }
    }
}

Properties

Property Description
WarningIndicates the message is a warning.
ErrorIndicates the message is an error.