How Do I Display a Variable on a UMG Menu?

I’m trying to display a variable saved in a SaveGame blueprint on one of my game’s main menus, which is made with UMG, but I can’t figure out how to get the variable into the UMG widget’s script and then display it onscreen. Can anyone help me?

What exact problem do you have?

In your widget, create a Text(I assume you’re trying to display text/numbers), place it anywhere in the Canvas you like. Select the Text you placed → at the Details panel → find Content → press Bind → Create Binding → then setup like this.

The Cast to SaveGame node isn’t giving me the option to get the variable from it (the variable is set to public, though).

Ah, try this, create a variable in your widget, type set to the SaveGame widget, then get a Get SaveGame node, and try getting your variable from that node. Check the edited answer.

Since widgets are container like, you will want to separate the widget that contains these information. It would be nice to know more about your actual setup to give you a hint how you could structure this and how you could get the variable.

Let’s assume you have a menu somewhere, where you want to list 3 SaveGame Slots. You want to list the Character Name that your Player took and maybe a time when the game was saved last.

Everything around the visual slots can be made before hand, but i would create an extra widget that fits these slots and contain information about your savegames. Now you could name your savegames for example “Savegame1” “Savegame2” and “Savegame3”. This would allow you to run a for loop from 1 to 3 and append the number to the word “Savegame”. Then you could check if the Savegame exists and if yes, you load the savegame and create the extra widget for it.

When you create variables in the widget, you can set them to “Editable” and “Expose on Spawn”. With this they will appear in the “Create Widget” node once you selected this widget class to spawn. Now you can easily fill the variable directly on creating the widget. And after that, add the widget as a child to your visual slots of the other widget.

To make this easier, you can do the for loop thing inside of the main widget that has the 3 slots for the savegames.

So… if this is not what you want, then you will need to tell us your setup. But you see, there are different ways that are quiet easy and dynamic to build once you know what you want to achieve (: