gasgiant / Markup-Attributes

A Unity Editor extension for customizing inspector layout with attributes.
MIT License
289 stars 11 forks source link

HideIf inside a shader doesn't work for me #9

Closed forestrf closed 2 years ago

forestrf commented 2 years ago

HideIf inside a shader doesn't work for me:

Properties {
  [Toggle(UNLIT)]
  _Unlit("Unlit", Float) = 0

  [HideIf(UNLIT)]
  _A("A", Range(0, 1)) = 0

  [HideIf(UNLIT)]
  _B("B", Float) = 0

  [HideIf(UNLIT)]
  _C("C", Color) = (1, 1, 1, 1)

  [ShowIf(UNLIT)]
  _D("D", Range(0, 1)) = 0

  [ShowIf(UNLIT)]
  _E("E", Float) = 0

  [ShowIf(UNLIT)]
  _F("F", Color) = (1, 1, 1, 1)
}

With this test code, HideIf isn't working but ShowIf (and the rest of the tags in this repository) work.

imagen imagen

When HideIf should be showing the property instead it seems to show an invisible, 1 pixel tall item where the property should be so I assume it is trying to do it. HideIf does work on [Toggle] properties.


Unity 2020.3.36f1 (Latest 2020 version). Windows 10.

gasgiant commented 2 years ago

Hi! Tried your code in 2020.3.36f1, doesn't seem to break for me. Could you try to replicate it in an empty project?

forestrf commented 2 years ago

You are right, sorry, it does indeed work in an empty project, it must be something on my project giving problems. I will try to find what it is. Thank you a lot and sorry for the trouble. Thanks a lot for this asset.

forestrf commented 2 years ago

Found the problem, I had a custom HideIf material property drawer in my project since probably several years ago and forgot about it. Removing it fixed it (nothing was using it anyway).