There is often a need to set some property based on the value of another property. A common example: adjusting blend settings based on the desired blending mode or setting stencil refs in a user-friendly way (like for outlines).
The signature should look like this
%SetProp((<shader condition>), <prop name>, <value if true>, <value if false>);
Example:
// properties
[Toggle(OUTLINE_ENABLED)]_OutlineEnabled("Enable Outline", Int) = 0
UI_SetStencilOp("Stencil Op Settier %SetProp((OUTLINE_ENABLED), _StencilOp, 2, 0)", Int) = 0
[HideInInspector]_StencilOp("Stencil Op", Float) = 0
// below in the pass
Stencil
{
Ref 69
Comp Always
Pass [_StencilOp]
}
// below in the CGPROGRAM
float _StencilOp;
This will set the Stencil Pass op (via the _StencilOp property) to 2 (Replace) if the OUTLINE_ENABLED keyword is set, or to 0 (Keep) if the keyword is not set
There is often a need to set some property based on the value of another property. A common example: adjusting blend settings based on the desired blending mode or setting stencil refs in a user-friendly way (like for outlines).
The signature should look like this
Example:
This will set the Stencil
Pass
op (via the_StencilOp
property) to2
(Replace) if theOUTLINE_ENABLED
keyword is set, or to0
(Keep) if the keyword is not set