Ability to add enum argument to button functions

A feature I would love to see is for buttons to be able to call functions with an enum type argument for instance…

public enum type {
  fire, water
}

public void SetType(type t) {
  //content
}

Currently buttons don’t acknowledge these functions as being available. It would be incredibly nice if we could not only see these functions, but assign an enum value to pass in.

12 Likes

It would be nice. Until then, having a string or int version of the function that then calls the enum version of it would be a usable workaround.

Also requesting this! It would be very handy to have “safe” inputs on our buttons.

2 Likes

Hmm… Something like this, are you thinking?

[RangeParameter(0f, 100f)]
public void SetSomeFloat(float param) {

And then the UI displays it as a slider?

Hi, we’ll take this as a feature request. It won’t make it in for v1.

12 Likes

Any time is better than never. Thanks Tim!

1 Like

Any update on this feature implementation yet?

1 Like

I was just hoping to use this feature myself for level control :]

1 Like

This would be awesome (if it works for custom defined PropertyDrawer and DecoratorDrawer), although if ever multiple parameters are going to be supported, then its probably necessary to put the attribute on the parameter:

public void SetSomeFloat([RangeParameter(0f, 100f)]float param) {

However, I am not sure how the current interface of the PropertyDrawer could fit in here (as the drawer usually gets a whole line to play with and should print out the property label as well - which can even be potentially larger.

Still… IMHO, an robust UI for an event system is a big big plus for Unity. (You also should put someone to look into displaying dynamically registered events in the UI during playmode. Its not impossible. Just hard. And you are about solving hard problems, right? :stuck_out_tongue: )

+1, was looking for this feature.

I also need this

Would be great to have, thank you!

Any news on this?

1 Like

Same here… would like to have this feature as well!

2 Likes

Given the existence of System.Enum.Parse, isn’t it pretty straightforward to create an overload of your event method that accepts a string parameter?

Yes, it’s straightforward but the results are less satisfactory. With a string, you’re not restricted to inputting only valid names. With an enum, you can’t make a typo.

It’s been a year already. Enum parameters isn’t a fancy or complicated feature, but it needs to happen.

9 Likes

Agree!

2 Likes

Ah waiting for this. It would be useful :slight_smile:

Would like this as well, my work around at the moment is to pass a script and have that script have the type.

Another drop in the bucket.

1 Like