Passing Game State Information to Widget Blueprint (UMG Menu) Good Practice

Hi everyone could someone please help me with a recommendation on a good practice for passing game state information from CPP to a UMG Menu (Widget Blueprint)? Being fairly new to the engine & CPP I am hesitant to try a method that may not be optimal for performance or ease of later development and use. I did find this nice tutorial by Rama that seems to cover what I might be looking for, but I am wondering what tradeoffs may exist by using this approach.

Looking at the shooter game project I see an namespace containing an enum that seems to provide a basic set of game states that I would like to use something similar to for menu decisions in blueprints.

namespace EShooterMatchState
	enum Type

Are there other popular ways that I may be missing to communicate game state information from CPP to widget blueprints? Thank you in advance for any assistance with these questions.

That’s a pretty open-ended question. It depends on what you want to do with this game state information.

Do you want to display to the user whether a match is started or not? Any user-facing text should be passed using FText (and UMG text blocks will request such), so an enum would not be helpful. It would be easy, however, to create an array mapping your enum values to text values.

Thank you cmartel for replying. At some point I would like to implement passing text along, although in this case I would simply want to pass basic information for the purpose of knowing which menu/UI should be displayed by default.

I think you can refer to this Basically, you create your own class in C++ extending UUserWidget, expose variables that you want by making them UPROPERTY(), then create your UMG blueprint extending that class. The blueprint will be able to access all variables you exposed from the C++ class.

Then yes, tagging the enum with UENUM( BlueprintType ) will allow it to be passed to/from UMG and other blueprints.

The larger topic is how to communicate with UMG, and that will depend mostly on what you’re most comfortable with. You can create a 100% blueprint UMG widget and provide it with some class to query, or you can create a native C++ base class for a UMG widget and move a fair amount of UMG logic to native.