Greetings, new developer here. Looking for some help with this tricky problem I’m trying to solve. I have a radial menu that fails to remove from parent in a very specific scenario.
Basically whenever I fist load up the editor or launch in stand alone I am unable to remove the menu from parent. In editor mode after the first initial play ( as in I hit play Esc out and hit play again, the process of removing from parent works flawlessly.
However when I launch in stand alone it is always the case that I’m unable to remove correctly. I have checked to make sure I’m not spawning multiple instances of the widget when its created, even going so far as to get all widgets of class and printing each to string yet I always only find the one existing.
What is really strange is that I have tried a remove all widgets with a do once proceeding it, and after this is called I am able to then use the spawn and de-spawn the menu correctly… for many reasons this will not work as I require other widgets not to be removed. Any Help would be greatly appreciated, I’ve looked everywhere and cant seem to find a solution.
However when I launch in stand alone it is always the case that I’m unable to remove correctly.
The first thing I’d try would be to step through all the Construction Scripts and Actor Constructors, perhaps there’s some abandoned debugging script? Also, do you have any C++ you might have forgotten about?
for many reasons this will not work as I require other widgets not to be removed
As a quick hack you could be more specific with the class of the widget you wish to remove:
Hello, thanks for the response. Yes, I tried getting all widgets of its specific class as well, Seems it was not getting a return on the widget with top level only set to true. So for some reason its not a child of the viewport if I understand that correctly.
No C++ at this point
What i did find taking apart the widget some to see if I could back track to a working version was If I don’t call a specific function in the construction scrip it works.
The function is a for loop that creates widgets for the items that should be contained in the menu and add them to an array to reference later.
Not sure exactly where I should have this or why its preventing the widget to be removed the first time its opened.
You’re Adding Unique - what are the chances a rejected widget becomes orphaned and just hangs around in the Viewport. It will not be garbage collected because the Viewport keeps it alive (until it’s removed ofc)
Another approach is to not work with the Viewport directly. But with a full screen canvas instead. Treat this master widget canvas as if it was the viewport. You get position, zOrder, and all the bells & whistles of the viewport + lots of additional features, like anchors. And you’ve encapsulated the entire radial menu in a single widget. Fewer chances of losing a reference this way. Win-win imho.
Some place onTick - GetAllWidgetsOf(theoffending)Class and count them. You know how many there should be vs how many are there. What do you get? Do the numbers add up?
Well print string says that it is indeed only creating the expected number. Ill try fiddling around with the add unique though to see if that is the issue.
I had previously thought that and added an isvalid check using a get from the menu slots array with the loop index, but it didn’t solve it so I reverted back.
I’m not sure I follow with not working with the viewport though. Can i add the menu slot widgets in some other way? Still pretty new to all this so it might just be a knowledge gap there.
The radial menu and the number of slots are created dynamically so I’m not sure how it would fit together.
Included a few more screen shots of the construction script, Maybe I’m just messing it up there somehow.
Not only would it work well together but it would also allow for more control and flexibility, and one can preview it all in real time, without launching the game. This is very quick & fairly dirty:
Do note that this is a single widget, you can have many of them (maybe irrelevant in your case since you may only need 1 ever) but you can manipulate it at a whim. Let’s say I want to hide it → I hide just this one widget. If I wanted to display it over or under another widget, I need to manipulate only this one widget.
And since it’s a container, you do not need an additional array:
The panel is an array. This can dramatically simplify things as script inevitably gets more and more convoluted.
Coool! Alright well ill get to work implementing this and see how it goes. At the very least I know where the problem is now. Thanks for all your help!
Still stumped on why it works perfectly in pie after the initial hiccup or in stand alone after that hacky remove all widgets test though. A true unreal mystery
Also, i just finished setting it up like you demonstrated, Works like a charm!
I ended up just adding the children to the old array seeing as i couldn’t find that node. didn’t even have to change my other code and it worked.