How to cycle create UI_COMMAND?

I am adding a lot of “toolbar buttons”

I do not want to write this code: (Because there is too much repetition)

I want to cycle create UI_COMMAND

like this:

A command with name CommandList[i] already exists in context MapEditor2D

How to cycle create UI_COMMAND?

you can simply use the function used by the macro :

#define UI_COMMAND( CommandId, FriendlyName, InDescription, CommandType, InDefaultChord ) \
	UI_COMMAND_Function( this, CommandId, TEXT(LOCTEXT_NAMESPACE), TEXT(#CommandId), TEXT(#CommandId) TEXT("_ToolTip"), "." #CommandId, TEXT(FriendlyName), TEXT(InDescription), CommandType, InDefaultChord );

in this case it would give something like :

UI_COMMAND_Function( this, CommandList[i], TEXT(LOCTEXT_NAMESPACE), TEXT("GenCommandName")+i, TEXT("GenCommandName")+i, TEXT("_ToolTip"), "." #CommandId, TEXT("test button"), TEXT("i'im note"), UserInterfaceAction::Button, FInputChord());

that should work ! :slight_smile:

edit: ok took me too long to answer ^^

I got it, I use UI_COMMAND_Function

Thank you :slight_smile:

Hi, I have the same problem.
Can you please share with me your full code of how you use UI_COMMAND_Function in for loop?