Issue with casting to a UI from another UI.

I’ve been trying to figure out one issue that I have with casting from one UI to another. After looking at some other posts, turns out there’s not just one answer for this, so I’ll give some context before describing the main issue.

I have a Main Menu that is split into three sections named Section 1, 2, and 3. Section 1 is the left panel (similar to the one that you can expand by hovering over it from Fortnite), where you can quit the game, access the options and quick functions etc. Then there’s Section 2, in which the main game logo sits, together with a Quick Info box which displays summarized information about anything that the mouse is hovered over and has different default displays for each tab on Section 3. And lastly, Section 3 is the one in which you can switch tabs to display different pages (like in Counter-Strike 2).


(Not a finished menu just yet.)

The issue is that all of these sections don’t sit within the MainMenu altogether, they are displayed there as different UIs in different spaces, because to keep things more organised (which was a really bad idea now that I look back on that decision), I made all of these sections a separate UI blueprint in the Content Browser.

image

The issue now, is that whenever I want any of these buttons to do anything within the big space under the Section 3 tabs, I have to cast to the MainMenu, because the widget switcher that controls these tabs sits in there.

And I hate casting. Because I never know what to put for that ■■■■■■■ Object value.

Users from other questions like these say that I need the reference to the Main Menu as the object, but I have no idea how to get it, because I’ve tried all object references to do with UIs in the variable types, tried all sorts of Get User (something), I have no idea where to get it from.

I really regret making these sections separate widgets now.

Any help would be appreciated.
Thank you!

After about 10 minutes, I’ve fixed the issue on my own.

Turns out that every single Widget Blueprint that’s created automatically gets its own variable type named after itself, and it’s the only thing that you need. You don’t even need a cast node, you just make the variable, call it MainMenuREF or something, then drag and drop it into your Graph space then drag out a connection and get a reference to any element of the UI that you want.

Problem solved.

Update: Nevermind.


I HATE CASTING.

I’m gonna lose my mind.
Please help. Anyone.

YET ANOTHER UPDATE:

I decided to just integrate the separate sections into the Main Menu so I don’t have to go through this chaos.

But we can still use this as a topic and leave responses on here for others who might have this issue.

Good luck to all of those that do.