Hello, I have a problem regarding User Widget that I cannot comprehend at all what’s going on.
I have widget class named “Dice” that is spawned upon Wrap Box.
I’ve made myself a debug button with “Clear children” node to remove all of those Dices and it works properly there and triggers Event Destruct node in them.
However, due to one planned functionality of the dice, when one custom event is called inside it, if requirements are met, it is supposed to destroy itself manually. For that, I added “Remove from Parent” with Target “self” in that function.
Now the strange thing is, even though it has nothing else that is supposed to have reference of it, which from I read should cause this object to be grabbed by garbage collector and removed, it stays in the Wrap Box it was spawned in.
For a moment, I thought it just didn’t removed the child from Wrap Box properly but when I added “Has any children” for debug, engine returns “false” for this Wrap Box that “spectre” Dice is in.
When checked with Widget Reflector, you can see that Dice widget in the Wrap Box though, giving clue that it is indeed has children to contrary what “Has any children” node returns.
When trying to use my debug button to remove all children from all Wrap Boxes, it doesn’t affect that “spectre” Dice widget.
Now even weirder thing with this “spectre” Dice widget is the fact that you can interact with it and use Drag&Drop function and move it to another Wrap Box as you normally could with any other Dice widget. After that, the widget suddenly acts like a normal Dice widget but leaves behind a copy in the original spot that suddenly can’t be interacted it again.
When checked with Widget Reflector both Dice widgets (the one moved to another Wrap Box and in the original Wrap Box) do exist both at the same time and even share the same address in memory.
In this case, when using debug button to remove all children from Wrap Boxes, it removes the Dice widget moved to another Wrap Box but still doesn’t affect the “spectre” Dice widget in original Wrap Box. For some reason, doing that allows to interact with that original “spectre” Dice widget again!
I tried removal methods including “Remove from Parent -self” node, on creating Widget adding object reference to that Wrap Box and index to the Dice widget during construction and then using those variables for “Remove child At” but the result is the same and my confusion is insufferable as I dont know why this happens at all.
If this issue won’t be resolved this creates kind of a big problem as functionality to remove that Dice widget is important to game rules and simply using a workaround and hiding the widget and moving it to separate container means that memory will still be used for something that does not need to exist and that is just a bandaid solution.
Any ideas how to fix that issue or better, how to remove properly a widget that is a child by its own instead of trying to remove it by parent?
I’ve made a video on YouTube so you can see in practice how this looks like: YouTube Video