Reputation: 59
I would like to make a simple UI with sliders that change properties in my shader.
I have a few properties declared in the shader like this:
name ("display name", Range (min, max)) = number
but the properties have different ranges, and the sliders are created dynamically based on the number of properties.
I would like to know if there is a way to access the range of said shader properties so that I can set a max and min value to my sliders.
Upvotes: 1
Views: 1299
Reputation: 125305
No. This is not possible. You cannot access the range min and max values in Range (min, max)
from C#. You have two options:
1.Hard-code the min, max values from C# in a constant variable. Make sure that they match the values in the Range (min, max)
function.
2.Hard-code the min, max values from the shader itself then use HideInInspector to hide them from the Inspector since you only need to read them.
[HideInInspector]
min("Min", Float) = 0
and
[HideInInspector]
max("Max", Float) = 1
You can now read them from C# as a float
with the Material.GetFloat
function. Make sure that they match the values in the Range (min, max)
function.
Upvotes: 2