Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

VisualElement.ReleaseResources

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void ReleaseResources();

Description

Releases reusable resources associated with this element and makes the element unusable.

The element must not be part of a hierarchy nor have any children, otherwise an InvalidOperationException is thrown. Calling this method makes the element unusable. Only call it when the element is no longer needed. Exceptions are thrown if you modify the element or add it again.

By default, a VisualElement releases its reusable resources only when it is garbage collected. Calling this method explicitly releases those resources earlier so the system can immediately reuse them when creating new elements, reducing memory usage.

In most cases, it is more convenient to use VisualElement.Clear on a root element which will recursively remove all its descendants and call ReleaseResources on each of them.