Display a function param as it was an 'enum' in Blueprints?

Hey!

Is it possible to have an FName (or int, bool, something…) function param displayed as it was an enum? So the user would only see two options, and depending on which one is selected from the dropdown menu, the function’s param is filled out with the corresponding value.

A bit more context. I’m working on a matchmaking plugin, and I ran into a small issue. When dealing with online sessions, you have to specify an FName, which will be used to differentiate between session types. It’s either GameSession or PartySession. In C++ there are dedicated macros for these which are obviously unavailable in Blueprints.

“Well why aren’t you just create an enum?” - Yes I can make an enum and use that, but since this is only needed for blueprint functions, I’d like to avoid that if possible.

Not sure if this falls in the “Well why aren’t you just create an enum?”-Category for you. You could create two distinct functions that simply return either the GameSession name or the PartySession name. Of course this doesn’t prevent the user from entering some other name, but besides adding a check(), ensure() or log I doubt there’s a better way than the enum. You could even create a whole new ustruct for that does nothing more than wrap a ReadOnly FName which you can only make with those two functions.

I had different functions before, but I switched over to using proper callback proxy objects which means each online blueprint function have to have its own class. It looks like enum is the way to go.

Edit: One more thing that comes to my mind is creating static blueprint pure functions that would return the C++ macro FNames? Like GetGameSessionName. That could work as well.

I accidentally stumbled upon a possible solution. Haven’t tested it because I don’t need this anymore. I’ll just share for future reference.

// [PropertyMetadata] Causes FString and FName properties to have a limited set of options generated dynamically, e.g. meta=(GetOptions="FuncName")
//
// UFUNCTION()
// TArray<FString> FuncName() const; // Always return string array even if FName property.
GetOptions,
1 Like