Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add %SetProp() drawer function #29

Closed
orels1 opened this issue Jul 29, 2023 · 0 comments · Fixed by #38
Closed

Add %SetProp() drawer function #29

orels1 opened this issue Jul 29, 2023 · 0 comments · Fixed by #38
Labels
feature Feature reqyuests
Milestone

Comments

@orels1
Copy link
Owner

orels1 commented Jul 29, 2023

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

@orels1 orels1 added the feature Feature reqyuests label Jul 29, 2023
@orels1 orels1 added this to the 6.2.0 milestone Jul 29, 2023
@orels1 orels1 mentioned this issue Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature reqyuests
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant