Max no. of elements in [Enum] attribute

I am trying make a properties selectable with [Enum] attribute, e.g [Enum(A,0,B,1,C,…)].

But i find that the compile have warning when more than 7 elements. Is that a max limit for enum attribute elements?

1 Like

No, I think the max is quite a lot more than that (or maybe not in shaders?). What warning do you get exactly?

What is the [Enum] attribute? Is this some custom thing in your project?

Enum’s themselves can have significantly more than 7 elements, so this isn’t the issue.

@LaneFox
At last , find the limit state in doc.

“up to 7 name/value pairs can be specified.”

Their example of using the UnityEngine.Rendering.BlendMode enum in relation to that comment is a little odd since that enum has far more than 7 elements. You can always use a custom material editor if needed, or write your own MaterialPropertyDrawer that can allow for more elements. I’ve never tried it myself, but you could also try creating a custom enum in a C# script and seeing if you can use that in the [Enum(MyCustomEnum)]?

@bgolus Thanks. Originally, I am using a Enum in c# script. But i need to make the shader independent, so i run in to this problem.