Create widget best practices?

Good day! Sorry for newbish question, but still:
If we are talking about menu widgets, which class should create 'em and add to viewport ?

Let’s consider the following case :slight_smile: I create the main menu with the standard buttons like “Start game”, “Settings”, “Exit”. On button click event, I validate some manager class and call its corresponding method.

In the following [tutorial][1] on youtube the author creates the events for button clicks and calls methods from GameInstance inherited class object. But as it is shown in the following article [ue4 docs][2]- for the pause menu PlayerCharacter creates widget and adds it to the viewport. And as third option, I’ve placed 'em into the game mode

So what are the best practices, where I should place such methods? For example, I need to have the possibility to create a widget for setting from 2 places: the main menu and the pause menu. Duplicating creation methods doesn’t sound right for me.

Thanks in advance!

I personally create widgets from my character pawn when I can, and from the level blueprint when I can’t (because there’s no pawn).

Seems legit :slight_smile: Thanks! But what about situation, when you need the same widget in different levels? Just duplicate creation? I know, it’s not a big deal to copy a couple nodes, but still…

That is what I do for outside-the-game levels. Each level blueprint opens its own widgets.

You could certainly do it some other way (there’s lots of ways you could get it done).

For example, you could make a blueprint that does your fancy menu handling in its BeginPlay, and then just drag an instance of that blueprint into each of the levels you want it to fire on.