Version: 6000.3
语言: 中文
访问脚本中的材质属性
在“检查器”窗口中控制材质属性

使用材质属性值设置着色器变量

使用材质属性在ShaderLab代码中设置变量

要在ShaderLabUnity 用于定义 Shader 对象结构的语言。更多信息
请参阅术语表
将材质属性名称放在 ShaderLab 代码中的方括号中。

此示例代码演示了使用材质属性将unitsShaderLab 的价值Offset命令。

Shader "Examples/MaterialPropertyShaderLab"
{
    Properties
    {
        // Change this value in the Material Inspector to affect the value of the Offset command
        _OffsetUnitScale ("Offset unit scale", Integer) = 1
    }
    SubShader
    {
        // The code that defines the rest of the SubShader goes here

        Pass
        {
            Offset 0, [_OffsetUnitScale]

           // The code that defines the rest of the Pass goes here
        }
    }
}

使用材质属性在 HLSL 代码中设置变量

要使用 material 属性在 HLSL 代码中设置变量的值,请为材料属性指定与着色器在 GPU 上运行的程序。更多信息
请参阅术语表
财产。

您可以在以下文章中看到此技术,其中包括工作代码示例:

访问脚本中的材质属性
在“检查器”窗口中控制材质属性