Best way to script menu screens?

General Widget Blueprint / Scripting question here…

Let’s assume I have a Main Menu widget with 2 buttons on:

  • PLAY (launches me directly into my game level using “Open Level” node)
  • LEADERBOARD (opens up a leaderboard screen…would have a “back” button on it to return to Main Menu)

My questions are:

  1. If I was to click on “Leaderboard” would I be best to “Remove from Parent” my created Main Menu widget BP and then Create / Add to viewport my “Leaderboard” widget BP? Or is there a better, more preferred way to engineer that? Know that I’d want ALL of this “menu flow” to take place within a “Main Menu” level I’d set up for the purpose of ONLY interacting with menu screens (NOT actually playing any of the main game.)
  2. Let’s assume I did the above but now I want to click on the “BACK” button within my “Leaderboard” screen. Is it best to “Remove from Parent” my created Leaderboard widget BP and RECREATE / Add to Viewport my Main Menu widget BP?

I basically want to know if I should be Removing from Parent the widget BP I no longer way to show and Creating / Adding to Viewport the widget BP I do want to show. I just feel like there may be a more elegant way to flow from one menu screen to another?

Hey. I’m quite new to Unreal so don’t completely trust this, but what i’ve been doing so far is simply toggling the visibility of parts in the Mainmenu HUD on and off once a certain button is pressed using the “set visibility” node.

Im also quite new but the way i do my hud is with animations and i just have everything off screen and comes onto screen via button click

Depends what exactly you want. I couldn’t quite grasp your particular functionality but I will say this… it sounds like you’d be best served with an “empty” level that contains the main menu widget. This widget gets created by the level blueprint. When you hit play it loads your first game level. Now the confusing part. This leader board, do you want that available all the time in any level? Then yes, set visibility to open and close it. If not, if this is something that only opens from the main menu I would overlay in on the main menu and when you click leader board hide the main menu, then when you hit back hide the leader board and reveal the main menu again.

Yeah, that’s essentially what I’ve done so far…I’ve got an “empty” level where I’m creating my main menu widget within (through the level blueprint.) I DO want this leaderboard to be available ONLY when the player is within the main menu (and then, once accessed / displayed, having the player return BACK to the main menu.) I haven’t yet explored going the “Overlay” route to displaying the Leaderboard from off of my “Main Menu” widget (for both screens…I want to STAY in my empty “Main Menu” level.)

Not sure if one approach or the other is more performant? Or if it even matters much for this small of a menu system?

I feel like there should be some sort of master “Widget BP” hierarchy asset that should exist that’ll automatically handle going from one widget BP to another when devs want to create layered menus!!!

I just make 2 menus and hide one. Lay one right over the other in the editor and toggle visibility accordingly.