so i am trying to do a card game and i have massive issues mith my UI.
when i draw the my array update juste fine, but if i do my right mouse bouton action it says that the Array is empty.
the lets mousse bouton action has 0 issue, even if i do it after my right mouse bouton.
in screesnchot 2 you can see the verry begening of my right mouse button action, there is literaly nothing before that.
Where is it contained? (What is the object blueprint shown in the screenshots?)
As you probably know the array holds only the address to your “card” objects. Where do the actual card objects reside? Can you show the moment of creation of those cards and in what object is that done?
You are most probably either deleting or letting the garbage collector delete your card objects.
the array is an object reference to my card template widget
every screen is from the same blueprint widget (W_Cards_Location)
My cards are all drawn of from a different Array (W_Actor Draw Pile) handled in an actor component
the widget just receive this array and transfer the item in the 0 index from W_Actor_Draw_Pile to the array Cards in Hand
I don’t think its a garbage collect issue because the widgets are all on screen and every left mouse click interaction works perfectly even after i attempt a bugged right mouse click interaction.
Update, after messing around trying to gather more infos i noticed the bug no longer happens if i don’t remove W_cards_location from parent (the parent is my general UI widget with just a canvas panel)
…the bug no longer happens if i don’t remove W_cards_location from parent…
Yea that is what I meant by “Where do the actual card objects reside?” I haven’t gone that deep into the code but probably removing them from their parent releases them for garbage collection. If I remember correctly, (I might not) widgets that are not attached to a viewport or widget component (or to another widget that is) are automatically garbage collected and this is not an issue/bug but is the expected behavior.
If you want to temporary hide them use SetVisibility - Hidden/Collapsed.
i managed to fix the bug, turns out the issue was nowhere near where i thought it was.
It came from my end of turn function who didn’t proprely reseted the variable “current_actor_turn”, so after the first turn my entire turn manager was off and tried to call functions from the wrong actor.
Also apparently if your widget is a variable from an active actor it is taged as not to be garbage collected so it works out perfectly for me.