Removes all child elements from this element's VisualElement.contentContainer.
Only the child elements are removed, not the element itself. Only the immediate children are removed. To remove all descendants, use the VisualElement.Hierarchy.Clear overload with the VisualElementClearOptions.Recursive flag.
| Parameter | Description |
|---|---|
| options | Allows which actions are performed when clearing the children. |
Removes all child elements from this element's VisualElement.contentContainer, using the specified options. Use this method to reduce memory usage.
Only the child elements are removed, not the element itself.
Using default options, only the immediate children are removed and no additional action is performed.
To remove all descendants from their parent, specify the VisualElementClearOptions.Recursive flag.
To invoke the VisualElement.ReleaseResources method on all descendants, specify the VisualElementClearOptions.RecursiveReleaseResources flag.
This flag implies that the hierarchy is cleared recursively, because an element must have no children when it is released.
You can use the combination of these flags to clear a large number of elements from the hierarchy and immediately release resources to reduce memory usage. For more information, refer to VisualElement.ReleaseResources.
It also removes internal parent and child relationships between elements, which can help with garbage collection speed and troubleshooting memory leaks.