Best way to efficiently toggle visibility of multiple stage selection buttons based on SaveGame data?

Hi everyone,

I am currently making a stage selection screen in Unreal Engine. I want to dynamically reveal stage buttons as the player progresses through the game.

Right now, I am planning to save variables like “Stage1_Opened”, “Stage2_Opened”, etc., in my BPSaveGame, load them on the stage select screen, and change the visibility of each button based on those variables.

However, I have 9 stages in total. If Stage 9 is unlocked, connecting 9 different button variables to a single Set Visibility node feels very inefficient, cluttered, and prone to bugs.

Is there a cleaner, more scalable way to handle this? For example, using Arrays or Loops? Any screenshots or Blueprint logic examples would be greatly appreciated!

Thank you in advance!

Hello!

I think using Bitmask Flags is not an ideal approach, because you’ll have to manually add more buttons and more items to the enum if you ever add a new stage.
But if you prefer it, I suggest you use a Map of Widgets to Enum values, and loop through that map:

But if you’re ok with a different approach, I suggest making your save data store an Array of Names, each representing a Stage. Then you make a custom Widget representing your stage select button, with a variable for the stage it represents. Finally, when you create your menu, you can dynamically generate the buttons and put them in a container (such as a VerticalBox, a GridPanel, etc.) like this:

Hi,

Building on the approaches mentioned above, a more scalable approach is to avoid separate variables like “Stage1_Opened”, “Stage2_Opened”, etc., and instead store progression in a variable.

For a linear progression system, a single integer such as “HighestUnlockedStage”:

You can create an array containing all your stage buttons, then run a For Loop through the array and compare the loop index against your highest unlocked stage value.

If the index is lower or equal, set the button visible. Otherwise hide it.

For non-linear progression, you can instead use a boolean array to check unlocked stages:

Thank you so much. Since the progression is linear, using an Integer instead of a Byte for the Stage variable makes a lot of sense. I learned something new!

Also, I have 9 buttons in total, and I successfully completed the setup by placing the first stage button into the index 0 pin of the Make Array node.