# ShaderData.VariantCompileInfo

> Information about a compiled shader variant.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public struct ShaderData.VariantCompileInfo
```

## Remarks

Represents the results of compiling a variant using [ShaderData.Pass.CompileVariant](/engine/6000.7/script-reference/unityeditor/shaderdata/pass/compilevariant.md). This struct contains the success status and potential error messages, as well as some reflection data alongside the raw shader binary output.

```csharp
using UnityEditor;
using UnityEngine;

// Adds a new Editor menu item called Example.
// Select a shader asset in the Project window, then select
// Example > PrintVariantCompileInfoExample from the Editor menu.
// Information of a compiled variant will be printed as debug log.
public class PrintVariantCompileInfoExample
{
    [MenuItem("Example/PrintVariantCompileInfoExample")]
    static void MenuCallback()
    {
        if (Selection.activeObject is Shader selectedShader)
        {
            // Get the first pass of the the first subshader
            ShaderData shaderData = ShaderUtil.GetShaderData(selectedShader);
            ShaderData.Subshader subShader = shaderData.GetSubshader(0);
            ShaderData.Pass pass = subShader.GetPass(0);

            // Compile a vertex shader variant without any keywords
            var keywords = new string[] { };
            ShaderData.VariantCompileInfo info = pass.CompileVariant(UnityEditor.Rendering.ShaderType.Vertex, keywords, UnityEditor.Rendering.ShaderCompilerPlatform.D3D, BuildTarget.StandaloneWindows64);

            // Log the information Unity has about the compiled variant
            if (info.Success)
            {
                Debug.Log("Compiled size: " + info.ShaderData.Length + " bytes");

                string msg = "Vertex attributes: ";
                foreach (var a in info.Attributes)
                {
                    msg += a.ToString() + " ";
                }
                Debug.Log(msg);

                msg = "Texture bindings: ";
                foreach (var tex in info.TextureBindings)
                {
                    msg += tex.Name + "-" + tex.Index + " ";
                }
                Debug.Log(msg);

                msg = "Constant buffers: ";
                foreach (var cb in info.ConstantBuffers)
                {
                    msg += cb.Name + "-" + cb.Size + "bytes ";
                }
                Debug.Log(msg);
            }
            else // If the compilation fails, Unity prints the errors
            {
                string failureMsg = "Compilation failed: ";
                foreach(var msg in info.Messages)
                {
                    failureMsg += msg.message + "\n";
                }
            }
        }
    }
}
```

Additional Resources: [ShaderData.Pass.CompileVariant](/engine/6000.7/script-reference/unityeditor/shaderdata/pass/compilevariant.md), [ShaderData](/engine/6000.7/script-reference/unityeditor/shaderdata.md), [ShaderUtil.GetShaderData](/engine/6000.7/script-reference/unityeditor/shaderutil/getshaderdata.md).

## Properties

| Property                                                                                                                        | Description                                                                                                                                                                                                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Attributes](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/attributes.md)                           | Vertex attributes the compiled variant uses (Read Only).                                                                                                                                                                                                                  |
| [ConstantBuffers](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/constantbuffers.md)                 | Constant buffers the compiled variant uses (Read Only). Some platforms don't have constant buffers; however, Unity reports all global constants/uniforms in a single constant buffer.                                                                                     |
| [Messages](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/messages.md)                               | Stores errors and warnings produced during compilation (Read Only).                                                                                                                                                                                                       |
| [ResourceBindings](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/resourcebindings.md)               | Detailed information about every resource binding the compiled variant uses, in a single combined array (Read Only).                                                                                                                                                      |
| [ShaderData](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/shaderdata.md)                           | Stores the raw platform-specific bytecode for the compiled shader (Read Only).                                                                                                                                                                                            |
| [SpecializationConstants](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/specializationconstants.md) | Specizliation constants the compiled variant uses (Read Only).                                                                                                                                                                                                            |
| [Success](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/success.md)                                 | Indicates whether the variant compilation succeeded (Read Only). If it did, it is true. Otherwise, this is false and [ShaderData.VariantCompileInfo.Messages](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/messages.md) contains the errors. |
| [TextureBindings](/engine/6000.7/script-reference/unityeditor/shaderdata/variantcompileinfo/texturebindings.md)                 | Texture bindings the compiled variant uses (Read Only).                                                                                                                                                                                                                   |
