Hello, good morning, I would like to know that, I assume not because when I press the play button on another level, the menu with the buttons does not appear.
How can I do it? Thank you.
Create and show the menu in another level as well.
I don’t want to recreate the buttons, texts, fonts and their settings again. That’s why I ask if it can be copied and pasted to another level, thank you.
What do you mean re-create? Just spawn the widget again. If you mean to preserve some menu settings between level, there are many ways. Save Games, for example. Use Game Instance. Ini files.
The best practice for this - to create a UI manager class for it (HUD class, for instance)
Put there any logic that will create and handle the UI behaviour, to enclose your UI functionality out of other project components. And interact with this from the any persistent object, as Everyone mentioned above.
You can use GameInstance to store the data, that you need to bring through the levels.
So, your communication schema may look like this
Also, it can be quite helpful, to check this
UPD: I didn’t mentioned it on schema, but your UserWidgets shouldn’t interact with the game environment directly. It’s a good idea to add event dispatchers them and transfer the calls through the UI Manager class in reversed direction. So, the main idea - to use only one class between the project environment and UUserWidgets, and store the required information in singleton objects like GameInstance.
That is, create a canvas, put a vertical box, inside a button, a text, go to the font, choose its size, color, location, etc. for all the buttons you want to create, for example. That’s what I mean when I say recreate.
I thank you but I don’t understand what you wanted to tell me. My question is simpler than that.
Okay, the thread title says about the copying widgets to another level?
Actually, I have no idea what do you mean under the level in this context, but, thank you for clarifying.
You can act with the UserWidgets with the same way how you acting with regular game objects. If you won’t to duplicate the functionality for Monster_Orc, Monster_Troll… you just creating a base class for it, or adjusting the object behaviour to react on the parameters changes.
So, you can create the UserWidget, drop the button(or whatever is required) there, set up parameters that you needed with pre-construction and public variables to them. And after this, you can:
- Use this UserWidgets inside of another widgets (you can add them with Palette), change their parameters.
- Create child class to override/extend the functionality.
And the good reference here