Search Unity

Question Hide optional shader properties

Discussion in 'Shaders' started by madGlory, Jul 20, 2020.

  1. madGlory

    madGlory

    Joined:
    Jan 12, 2016
    Posts:
    44
    Hello!

    I am trying to write a MaterialPropertyDrawer that will hide a property if a specific keyword is not enabled. I found another forum post with a solution to this problem:

    https://forum.unity.com/threads/sharing-is-caring-hiding-optional-material-parameters.349952/

    The main issue with this is that it ignores all other attributes because it is drawing the default shader property.


    Code (CSharp):
    1. if (bElementHidden)
    2.                 editor.DefaultShaderProperty(prop, label);
    Ideally i would be able to write this and it would automatically draw the rest of the properties (such as materialtoggle or rangeslider).

    Code (CSharp):
    1. if (bElementHidden)
    2.                 editor.ShaderProperty(prop, label);
    But calling the ShaderProperty causes a stack overflow. How could this be done to keep the other drawers?