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

ErrorCode

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

Uniquely identifies a type of error which may occur when generating reflection information.

Each value of this enum represents a different type of error, the details of which may be found in LogMessage.Text.

Additional resources: LogMessage.ErrorCode.

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
UnknownAn unspecified error occurred.
FailedToLexThe shader source code failed to tokenize.
UnexpectedEndOfFileThe shader parser reached the end-of-file marker while searching for a token.
UnexpectedTokenThe shader parser expected one token but found another.
UnmatchedScopeDelimiterThe shader source code lacked a closing brace.
UnsupportedShaderSyntaxThe shader source code made use of a language construct not supported by the shader API reflection system.
XMLSyntaxErrorA comment decorating a shader function contained malformed XML.
NestedHintContainerA hint tag was nested within another hint tag.
DeepHintA hint tag was nested within another hint tag.
AttributeHintA hint tag used an XML attribute.
NonexistentParameterAn XML tag referenced a nonexisted function parameter.
MissingParameterNameAn XML tag which requires a function parameter name lacked one.
MultiplyDefinedHintA hint was defined multiple times.