Skip to content

PropertyDrawers

Johannes Deml edited this page Mar 31, 2020 · 2 revisions

Custom Property Drawers (Code Source | Shader Source)

Configurable/Reference/PropertyDrawers

Custom Property Drawers Material

Configurable Shader offers a few subtle, but very useful Property Drawers for Material Properties:

HeaderHelpURL - MaterialDecorator

[HeaderHelpURL(Header Text, Protocol, URL)]

Input Description
Header Text The text shown in the inspector
Protocol Either http or https
URL The URL excluding https:// and substituting every / with a " " in order to use only allowed characters

The Header Help Url is similar to the Header Property with the addition of adding a help button with a link on the right side of the window.

EightBit - MaterialProperty

[EightBit]

Supported Types Description
Int 0 - 255

EightBit is uselful for all ints that are in the rage from 0 -255. The drawer clamps the input value in that range. Useful for stencil values or read write masks.

RangeMapper01 - MaterialProperty

[RangeMapper01]

Supported Types Description
Vector (lowerValue, UpperValue, not used, not used)

RangeMapper01 gets an input value between 0 - 1 and maps it to a subset so that lowerValue gets 0 and upperValue 1 with the formular value = (value - _Range.x) / (_Range.y - _Range.x); The range mapper can also just be used as a MinMax Slider between 0 and 1.

RangeMapper - MaterialProperty

[RangeMapper]

Supported Types Description
Vector (inLower, inUpper, outLower, outUpper)

Similar to RangeMapper01, but can be used for arbitrary in and out values. The suggested Formular is value = (value - _Range.x) / (_Range.y - _Range.x) * (_Range.w - _Range.z) + _Range.z; This maps an input value [x, y] to [z, w].

SimpleToggle - MaterialProperty

[SimpleToggle]

Supported Types Description
Float 0 - 1

Similar to Toggle, but without setting shader keywords.

Tooltip - MaterialProperty

[Tooltip(Text)]

Input Description
Text The text to show as a tooltip. Be aware that not all characters and not all words are allowed. The text is written without quotes.

A tooltip for Material Properties. Be aware that not every word and character is allowed here.

Tooltip - MaterialProperty

[Ramp]

Supported Types Description
Texture2D Drws the texture 2D in a stretched preview to show the ramp/gradient of the texture in x direction.

Draws a preview for ramp textures. Using this drawer immediately tells others in which direction the ramp happens (x direction) and that it will be used as a color ramp.