Download

Create widget doesnt work correctly

Hello everyone,

I have one menu with tabs. When you press each of the tabs it brings you different widgets (controls, options, changes ingame, etc).
This is how my widgets are made, its a very simple construction :

So you press one button, current widget disappears and the desired one appears.

Lets say I’m on the options menu (my_menu3 blueprint) and I go to (controls blueprint). Coming back to (my_menu3 blueprint) disables all my options. They dont work anymore.
Its like it creates a new widget, but all my event dispatchers are gone! I cant access to them.

I tried making a reference to my_menu3 BP an attaching it to my controls widget BP but it didnt work. Any ideas?
I’m making all these nodes in my Level Blueprint.

Hello,
To have the same widget, you need to create it on event begin play, “set” it as variable and use the variable in your flip flop to add to viewport / remove from parent. But to save infos you may be prefer use game instance (solo) or game mode (multi player) to have infos persistent.

Thank you for answering!
Where do I put my Event Begin Play? In my level blueprint?
Well I created this (screenshot) and Set a Variable from my menu widget (mymenuvariable).

http://a.pomf.se/agqorb.jpg

-Then I replaced this new variable in every place I used the previous one.

But it doesnt work :(.

If it helps, this is when all my event dispatchers stop working, pressing this button from inside my UMG menu. I replaced here my variable to “mymenuvariable”.

Am I making something wrong? I tried casting, creating another event dispatcher, almost everything but I cant find the solution.

Create your widget and set variable on event begin play.
Drag a get variable and use it to add viewport / remove from parent, and no more create new widget or set variable.
In your click event, you remove your widget before creating a new one, set your remove widget at the end of event, after creating new one. And you ahve to use the variable you ever created to add to viewport, not create and set a new one.

Lets see, following your instructions

Level blueprint :
I create the variable “nuvaria” from my my_menu_widget. And I replaced the older variables with this new one.

Widget blueprint (this is the button I press which redirects me to my_menu_widget):

1 - How can I use my “nuvaria” variable here? I created a new variable using My_menu widget as Variable type but it still doesnt work.

2 - If I put Remove from parent in the last place I cant go to my_menu widget anymore.

I think Im not getting it right…

if I’m reading correctly

You need to cast to whatever blueprint “Nuvaria” Variable is located. If it was your character it would be “Cast to MyCharacter” owning object would be Get player character and the return value you pull out a Get Nuvaria

So instead of creating a new variable that references the widget, you are just going to cast to wherever the variable is and pull the value of Nuvaria and set your Add to Viewport target to that

Variable “nuvaria” its located inside my Level BP, thats why I dont really know how to Cast it.

Can I create that EventBeginPlay -> Create my widget -> Set Nuvaria variable inside my Character and then Cast it from Level BP and Widget BP?

Here is a working example : you create your widgets and set them in level blueprint , then you set variable in both of them, in widget you used the variable :
af3d1421b2ce3cde69de1c44b9edcc853492f9a4.jpeg

On flip flop, you remove all widgets as you don’t know which one is the current added to viewport.

Edit : if you create your widgets in character or in game instance you then only have to get character or get game instance / cast to used bp character or used bp game instance / drag variable from return value and no more need to have variable in widget and set it, but you can set it too on start as in the example and no more have to call them. Set variables in widget will be ok if you have two or three widgets but if you have 4 or more variables to use in each widgets using a get instance would be better.

Sorry for replying again, but theres no way I cant get those references inside my Widgets.
I am creating them by Adding a new variable, searching for my widget’s name and then writing the same name as they have inside Level Blueprint, obviously this doesnt make the trick.
Then again, in the widgets if I put Remove from Parent at the end of the event, my menu doesnt appear. Im assuming this has to be because Im creating a wrong reference for my widget.

http://a.pomf.se/aywupl.jpg

I hope with this I can finally figure out how to do all this mess from scratch.
Thank you for your time.

No trouble to ask again, this is the goal of the forum, helping ^^ : You create a variable in your widget, select for variable type the type of the other widget. compile and save both. On event begin play, you drag from return value node of create widget (or from “set variable” as in example, this is the same) a wire and type “set” name of the variable", then you set it with other widget value.

Awesome Fen, it finally worked!
I was creating the wrong references all the time and they needed to be swapped between.

Thank you so much! , Ive learnt more things than expected :slight_smile:

Happy that helped you ^^