I have a widget with inputs and logic inside.
once I remove from parent it stays getting the inputs and
acting. I dont understand why epic did the destruction of widget different
to actors. It is supposed the way to ‘destruct’ a widget is just by removing
from parent but it seems that is false. even setting the widget to disable
before removing from viewport it stays receiving inputs and working.
no is not working…even the SET INPUT MODE UI ONLY node
has a connector for a widget it overrides the whole game inputs so
the widget stops triggering inputs but the whole game does the same.
I dont want to put some stupid IF conditions to every input just to ignore
the undestructable widget
Upon unloading the widget with “Remove from parent” you need to clear all references to it in the blueprint variables and call Collect Garbage.
It will be cleaned up and stop taking inputs. If any references to it will not be set to nothing (like my set node at the bottom) it will remain in memory and take further inputs.
I suspect the only BP references to the Widget are the input key node bindings.
Is there a way of unbinding? If not I can try moving this logic to PlayerController
or somewhere else.
You can clear the reference by setting it to “select asset” it basically makes it a nullptr to be cleared by the garbage collector. @Everynone has the right idea with using the enhanced input mapping context. I guessed you might be using the old legacy input for your own reasons.
you are right I am using legacy inputs because I am a lazy old animal LOL.
anyway do you think my problem with the immortal widget is because it uses Input nodes in the BP? if so I will go for the supercool new enhanced inputs
add…later it removes itself so nop need to set anywhere.
Garbage has yet to be removed from memory, though. It clumps up objects together first into a neat bundle, waits (up to a minute or thereabout) and then releases it. You can force early garbage collect but it may choke a bit.
the immortal widget is because it uses Input nodes in the BP
The thing is that before UE5 and EI, you would not be able to do this:
So it was not even an issue. You had to override on key down (which you still can!). Now we can use direct input in widgets so the legacy system becomes… unusable in this very fashion.
note I included an input in the widget on purpose.
everything works perfect…all widgets are actually removed and deleted even having an input so my problem is not that. I guess I still having it referenced somewhere but i dont have idea because I just create the widget and later I remove it from widget…no SETS.
will watch for the reference viewer…I mean…I access the widget from other actors but as getter…I never store a reference of it (at least that is what I think)