docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TestContentLoader

    TestContentLoader is a class that loads test content bundles. It is used to load test content for graphics tests. It provides methods to load, unload, and reload test content. It also provides methods to check the load state of the content bundles.

    Inheritance
    object
    TestContentLoader
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools.Graphics
    Assembly: UnityEngine.TestTools.Graphics.dll
    Syntax
    public class TestContentLoader

    Constructors

    TestContentLoader(IEnumerable<TestContentBundle>)

    Constructor for the TestContentLoader class. This constructor initializes the content loader with the specified content bundles.

    Declaration
    public TestContentLoader(IEnumerable<TestContentBundle> bundles)
    Parameters
    Type Name Description
    IEnumerable<TestContentBundle> bundles

    The content bundles to load.

    Methods

    AssetPath(string)

    Gets the path to an asset within the content bundles. This method is used to get the path to an asset within the content bundles. It searches through all the content bundles to find the asset with the specified name.

    Declaration
    public string AssetPath(string assetName)
    Parameters
    Type Name Description
    string assetName

    The name of the asset to get the path for. This name is used to locate the asset within the content bundles.

    Returns
    Type Description
    string

    The path to the asset within the content bundles.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the content bundle has not been loaded.

    GetTestContentBundles()

    Gets the test content bundles. This method is used to get the test content bundles for the current platform.

    Declaration
    public static IEnumerable<TestContentBundle> GetTestContentBundles()
    Returns
    Type Description
    IEnumerable<TestContentBundle>

    An enumerable of test content bundles.

    LoadContent()

    Loads the content bundles. This method is used to load the content bundles for the graphics tests. It loads the content bundles asynchronously and tracks the load state of each bundle.

    Declaration
    public void LoadContent()
    Remarks

    This method is called when the test content loader is initialized. It loads the content bundles in the order of their priority. The content bundles are loaded asynchronously to prevent blocking the main thread. The load state of each bundle is tracked to determine if the content load is complete.

    Load<T>(string, out string)

    Loads an asset from the content bundles. This method is used to load assets from the content bundles. It searches through all the content bundles to find the asset with the specified name.

    Declaration
    public T Load<T>(string assetName, out string loadMessage) where T : Object
    Parameters
    Type Name Description
    string assetName

    The name of the asset to load. This name is used to locate the asset within the content bundles.

    string loadMessage

    The load message for the asset, indicating any errors that occurred during loading.

    Returns
    Type Description
    T

    The loaded asset of type T. This asset is loaded from the content bundles and can be used in the test.

    Type Parameters
    Name Description
    T

    The type of asset to load. This is used to specify the type of asset to load from the content bundles.

    ReloadContent()

    Reloads the content bundles. This method is used to reload the content bundles for the graphics tests. It unloads the existing content bundles and loads them again.

    Declaration
    public void ReloadContent()

    Reset()

    Resets the content loader.

    Declaration
    public static void Reset()

    UnloadContent()

    Unloads the content bundles. This method is used to unload the content bundles for the graphics tests. It unloads the content bundles to free up memory and resources.

    Declaration
    public void UnloadContent()

    WaitForContentLoadAsync(TimeSpan)

    Waits for the content to load. This method is used to wait for the content to load before running tests.

    Declaration
    public static IEnumerator WaitForContentLoadAsync(TimeSpan timeout)
    Parameters
    Type Name Description
    TimeSpan timeout

    The timeout for the content load. If the content does not load within this time, a TimeoutException is thrown. This is used to prevent tests from hanging indefinitely.

    Returns
    Type Description
    IEnumerator

    An enumerator that waits for the content to load.

    Exceptions
    Type Condition
    TimeoutException

    Thrown if the content does not load within the specified timeout.

    In This Article
    Back to top
    Copyright © 2026 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)