docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GraphicsTestData

    Loads the test data assets declared for one test case (see RequireTestDataAttribute): from the AssetDatabase in the Editor, from content bundles in players. Access it through TestData.

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

    Load<T>(string) and GetAssetPath(string) throw TestDataNotFoundException on a miss; TryLoad<T>(string, out T) covers optional assets. In players, wait for WaitForContentLoadAsync(TimeSpan) in a UnitySetUp method first.

    Properties

    AssetNames

    All addressable asset names in the declared test data sets.

    Declaration
    public IEnumerable<string> AssetNames { get; }
    Property Value
    Type Description
    IEnumerable<string>

    Descriptors

    The descriptors of the declared test data sets.

    Declaration
    public IReadOnlyList<ITestDataDescriptor> Descriptors { get; }
    Property Value
    Type Description
    IReadOnlyList<ITestDataDescriptor>

    Empty

    An empty instance, fresh per access: LoadMessage is per-lookup state, so a shared instance would leak diagnostics between callers.

    Declaration
    public static GraphicsTestData Empty { get; }
    Property Value
    Type Description
    GraphicsTestData

    HasData

    Whether any test data was declared for the test case.

    Declaration
    public bool HasData { get; }
    Property Value
    Type Description
    bool

    IsAvailable

    Whether every declared test data set has a backing store: in the Editor, each descriptor resolves to at least one asset; in players, each descriptor has a loaded content bundle.

    Declaration
    public bool IsAvailable { get; }
    Property Value
    Type Description
    bool

    LoadMessage

    Diagnostics from the most recent lookup.

    Declaration
    public string LoadMessage { get; }
    Property Value
    Type Description
    string

    Methods

    ContainsAsset(string)

    Checks whether a declared asset exists.

    Declaration
    public bool ContainsAsset(string assetName)
    Parameters
    Type Name Description
    string assetName

    The asset path, file name, or file stem.

    Returns
    Type Description
    bool

    True when the asset is present in the declared test data.

    GetAssetPath(string)

    The asset's path: the project-relative source path in the Editor (usable for raw file reads), the informational bundle path in players.

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

    The asset path, file name, or file stem.

    Returns
    Type Description
    string

    The asset path; never null.

    Exceptions
    Type Condition
    TestDataNotFoundException

    The asset is not part of the declared test data.

    Load<T>(string)

    Loads a declared asset by full asset path, file name, or file stem; the full path disambiguates assets sharing a file name.

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

    The asset path, file name, or file stem.

    Returns
    Type Description
    T

    The loaded asset; never null.

    Type Parameters
    Name Description
    T

    The asset type.

    Exceptions
    Type Condition
    TestDataNotFoundException

    The asset is missing or its bundle failed to load; the message lists what was declared, built, and searched.

    TryLoad<T>(string, out T)

    Loads a declared asset without failing on a miss; for optional assets.

    Declaration
    public bool TryLoad<T>(string assetName, out T asset) where T : Object
    Parameters
    Type Name Description
    string assetName

    The asset path, file name, or file stem.

    T asset

    The loaded asset, or null.

    Returns
    Type Description
    bool

    True when the asset was loaded; LoadMessage has the details either way.

    Type Parameters
    Name Description
    T

    The asset type.

    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)