Access material properties in a script
Control material properties in the Inspector window
Set shader variables with material property values Using material properties to set variables in ShaderLab codeTo set the value of a variable in your ShaderLabUnityâs language for defining the structure of Shader objects. More info
See in Glossary code from a material property, put the material property name in square brackets in your ShaderLab code.
This example code demonstrates the syntax for using a material property to set the units
value of the ShaderLab Offset
command.
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
}
}
}
Using material properties to set variables in HLSL code
To set the value of a variable in HLSL code using a material property, give the material property the same name as the shaderA program that runs on the GPU. More info
See in Glossary property.
You can see this technique in the following articles, which include working code examples:
Access material properties in a script
Control material properties in the Inspector window
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4