Hello folks…I’m ripping my hair out here! I want to continue my video series on my game development but am STUMPED at this problem.
Background: Works fine in my test project done pre-4.5, although a bit differently. I had all my UMG Widget stuff done on the HUD class.
I have since moved to 4.5 and started my video blog thingy using my old project as the template. But I got to this Level Select Menu part and can NOT get it to work! I have followed Rama’s example to create this level list, and that all works fine. Creating the buttons work fine, coloring the text, checking if it can be clicked (unlocked), and loading the level. But I can’t REMOVE this stinking level list. It MUST be something simple I’m missing.
Here is the stuff on the button:
When I click the button, everything works fine, but the isValid check ALWAYS comes back as invalid. I can’t figure this out for the life of me.
Someone, please, for the love of all that is good in this world, please, what am I missing? :mad:
Thanks!
Hello,
i was looking at umg when i saw this : Creating Widgets | Unreal Engine Documentation
Down of the page : In order to remove a child widget, you need to get your Parent and call RemoveChild. It may be your trouble. Try it instead of remove from viewport.
What about you use remove from parent and after that set the reference to null… maybe even hide it before and let the garbage collection do the work for you
I deleted the “Clear Children” node and replaced with “Remove Child” node…still no luck. Thing is, I’m not getting passed the “IsValid” check. You can see, in the second image above, my mouse was over the LevelSelectMainMenuConnection node, and is shown as referencing the correct Widget, but it still won’t pass the check.
Also, I tried bypassing the check and it still does not work.
My menu is created by: add the Level Select Main Menu (has title and a vertical scroll box [empty]). Then I add a button (child) to that scroll box for every index in my array (for each loop). The images above are on the actual buttons that have been added. Is it because I’m trying to do this from the added children? Does the removal have to be done from a specific level of the widget (i.e. from the parent)
For testing, I tried putting the function on the Main Menu, but with no luck.
Anyway, it seems it’s not seeing LevelSelectMainMenuConnection as a valid reference…why?
@ : I tried remove from parent, but not sure I get where you are saying to put it…can you clarify?
So where are you setting ‘LevelSelectMainMenuConnection’? In a construction script? Are the buttons being created within the parent’s construction script, or on ‘Event Begin Play’? Maybe you’re creating the buttons and setting that reference before it’s actually valid.
Well, I have it set up like this:
“Main Menu” widget is added to viewport on Begin Play with “Play” and “Options” button. When you click “Play”, a few things happen within the Main Menu widget:
LevelSelectMainMenu is created and added to the viewport, then each “LevelSelectMenuButton” is added. The buttons are added, labeled, colored and have values passed to them upon creation…so each button is unique. This is done by adding them as children to the LevelSelectMainMenu panel. So, now, I have a menu on screen that says “Select Level” with a list of levels below that, each labeled and colored differently based on whether or not the level has been completed(green), unlocked(white) or neither(dark grey).
the only functions on the buttons are what’s shown above.
My LevelSelectMainMenuConnection is added as a variable on the Button widget.
Here’s the breakdown (this all happens on the Main Menu widget…not the Level Select):
Thanks - that makes it a bit clearer, but I still don’t see where you’re actually setting the ‘LevelSelectMainMenuConnection’ value for each button. Adding it to the button widget as a variable only creates a null object reference of that type - you actually have to assign that reference at run-time in order for it to be valid. Based on your setup, you need to pass the parent level list widget into your ‘Create Button’ function, where you can assign it to ‘LevelSelectMainMenuConnection’.
From what I can tell, you’re just calling ‘IsValid’ on an unassigned local variable of type ‘LevelSelectMenu’ (on each button) - which will always report as invalid until it’s actually assigned to a created object.
AH HA! Chambered, you’re my hero. I knew it was something simple. I forgot to (didn’t think about) pass the value to my button. Works like a charm now…I just added a set to the variable and it’s working.
THANK YOU!
Certainly!
So, I first added the SET node in my Main Menu Widget, to set the variable that references the parent…
Then I just cleaned up my Button widget and used Remove Child. The Widget reference on my button is now valid since I passed the set variable from the previous image:)