Class TestContentBundle
Abstract class representing a content bundle for graphics tests. This class provides a base for loading and unloading content bundles,
Inherited Members
Namespace: UnityEngine.TestTools.Graphics
Assembly: UnityEngine.TestTools.Graphics.dll
Syntax
public abstract class TestContentBundle
Constructors
TestContentBundle(string)
Constructor for the TestContentBundle class. This constructor initializes the content bundle with the specified path. It extracts the name of the content bundle from the path and sets the priority based on the index in the name.
Declaration
protected TestContentBundle(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to the content bundle. |
Fields
m_LoadState
The current load state of the content bundle. This is used to track the loading state of the content bundle. It can be one of the values from the TestContentBundle.LoadState enumeration.
Declaration
protected TestContentBundle.LoadState m_LoadState
Field Value
| Type | Description |
|---|---|
| TestContentBundle.LoadState |
Properties
AlwaysReloadAssets
Whether to always reload assets from the content bundle.
Declaration
public virtual bool AlwaysReloadAssets { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
LogicalName
The logical name a test data bundle was declared under, or null for content bundles that are part of the global search. GraphicsTestData resolves its bundles by this name, so a bundle registered through RegisterBundle(TestContentBundle) must set it to serve the test data declared under that name.
Declaration
public string LogicalName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Name
The name of the content bundle. This is used to identify the content bundle.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
PartOfGlobalSearch
Whether the bundle participates in TestContentLoader's global asset search. Test data bundles opt out so their assets never shadow reference images (and vice versa); they are resolved only through GraphicsTestData via LogicalName.
Declaration
public bool PartOfGlobalSearch { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Path
The path to the content bundle. This is used to locate the content bundle on disk.
Declaration
protected string Path { get; }
Property Value
| Type | Description |
|---|---|
| string |
Priority
The chunk index parsed from the trailing "-N" of Name. Content bundles are loaded in ascending order of it. It does not affect the order they are searched in, which is the order TestContentLoader discovered them (most specific platform first).
Declaration
public int Priority { get; }
Property Value
| Type | Description |
|---|---|
| int |
State
The current load state of the content bundle. This is used to track the loading state of the content bundle. It can be one of the values from the TestContentBundle.LoadState enumeration.
Declaration
public TestContentBundle.LoadState State { get; }
Property Value
| Type | Description |
|---|---|
| TestContentBundle.LoadState |
Methods
AssetPath(string)
Gets the path to an asset within the content bundle. This method should be overridden in derived classes to provide the actual path logic.
Declaration
public virtual string AssetPath(string assetName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | assetName | The name of the asset to get the path for. |
Returns
| Type | Description |
|---|---|
| string | The path to the asset within the content bundle. |
ContainsAsset(string)
Checks if the content bundle contains an asset with the specified name. This method should be overridden in derived classes to provide the actual checking logic.
Declaration
public abstract bool ContainsAsset(string assetName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | assetName | The name of the asset to check for. |
Returns
| Type | Description |
|---|---|
| bool | True if the content bundle contains the asset with the specified name, false otherwise. |
GetAssetNames()
Enumerates the addressable names of the assets in the content bundle. Bundles that cannot enumerate their contents return an empty sequence.
Declaration
public virtual IEnumerable<string> GetAssetNames()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | The addressable asset names, or an empty sequence. |
LoadAsset<T>(string)
Loads an asset from the content bundle. This method should be overridden in derived classes to provide the actual loading logic.
Declaration
public abstract T LoadAsset<T>(string assetName) 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 bundle. |
Returns
| Type | Description |
|---|---|
| T | The loaded asset of type |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the asset to load. This type must derive from Object. |
LoadBundleAsync()
Asynchronously loads the content bundle. This method should be overridden in derived classes to provide the actual loading logic.
Declaration
public abstract Task LoadBundleAsync()
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous operation of loading the content bundle. |
Unload()
Unloads the content bundle. This method should be overridden in derived classes to provide the actual unloading logic.
Declaration
public abstract void Unload()
Events
OnBundleLoaded
Event that is triggered when the content bundle is loaded. This event is used to notify subscribers when the content bundle has been successfully loaded.
Declaration
public abstract event Action<TestContentBundle> OnBundleLoaded
Event Type
| Type | Description |
|---|---|
| Action<TestContentBundle> |
Remarks
This event is triggered when the content bundle is loaded. Subscribers can use this event to perform actions after the content bundle has been loaded.