docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CleanupUtil

    Provides a way to track and clean up objects that need to be disposed or destroyed after tests. When added to a test fixture, CleanupUtil will automatically clean up all objects that were added to be disposed or destroyed after the test execution.

    Inheritance
    object
    UITestComponent
    CleanupUtil
    Inherited Members
    UITestComponent.fixture
    UITestComponent.Initialize(AbstractUITestFixture)
    UITestComponent.Shutdown()
    UITestComponent.BeforeTest()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.UIElements.TestFramework
    Assembly: Unity.UI.TestFramework.Runtime.dll
    Syntax
    public class CleanupUtil : UITestComponent

    Methods

    AddDestructible(Object)

    Adds an object to be destroyed after the test.

    Declaration
    public void AddDestructible(Object destructible)
    Parameters
    Type Name Description
    Object destructible

    The UnityEngine.Object to destroy. This can be a GameObject, ScriptableObject, etc.

    AddDisposable(IDisposable)

    Adds an object to be disposed after the test.

    Declaration
    public void AddDisposable(IDisposable disposable)
    Parameters
    Type Name Description
    IDisposable disposable

    The object to be disposed of.

    AfterTest()

    Cleans up CleanupUtil after each test.

    Declaration
    protected override void AfterTest()
    Overrides
    UITestComponent.AfterTest()

    Cleanup()

    Cleans up all objects that were added to be disposed or destroyed.

    Declaration
    public void Cleanup()
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)