I found a potential bug or I am not understanding.
I call element.RemoveFromHierarchy();
This doesn’t seem to destroy it but just remove it as a check if the element is null is always false. Isn’t this suppose to destroy the element from memory?
Is there something missing?
There is no destroy on visual element, you could move it to another part of the hierarchy etc.
okay thanks. I guess I need to use a pool system then.
To clarify further, a VisualElement is a C# object, which means if you still have a reference to it, it won’t be discarded. If you want your particular instance of VisualElement to be garbage collected, you can assign null to it. If you want to reuse the same VisualElement, then yes, a pool system sounds ideal.
1 Like