Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LogMessage

Information about a problem that arose while reflecting shader code.
Read time 1 minuteLast updated 8 days ago

Definition

public struct LogMessage

Remarks

Use this struct to retrieve a data representation of any console messages logged while importing a shader include.

Examples

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

ErrorCodeThe message's error code.
LocationThe message's location.
MessageSeverityThe message's severity.
TextThe message's details.

Enums

Enum

Description

LogMessage.SeverityThe degree of failure associated with a log message.