Class AssetSource<T>
AssetSources are used to load assets from a generically within a Randomizer
Namespace: UnityEngine.Perception.Randomization
Syntax
public sealed class AssetSource<T> : object where T : Object
Type Parameters
| Name | Description |
|---|---|
| T | The type of asset to load |
Fields
assetSourceLocation
The location to load assets from
Declaration
public AssetSourceLocation assetSourceLocation
Field Value
| Type | Description |
|---|---|
| AssetSourceLocation |
Properties
assetRole
The asset role used to preprocess assets from this source
Declaration
public AssetRole<T> assetRole { get; set; }
Property Value
| Type | Description |
|---|---|
| AssetRole<T> |
count
The number of assets available within this asset source
Declaration
public int count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Methods
CreateProcessedInstance(Int32)
Creates an instance of the asset loaded from the provided index and preprocesses it using the asset role assigned to this asset source
Declaration
public T CreateProcessedInstance(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The index of the asset to load |
Returns
| Type | Description |
|---|---|
| T | The instantiated instance |
CreateProcessedInstances()
Instantiates, preprocesses, and returns all assets that can be loaded from this asset source
Declaration
public T[] CreateProcessedInstances()
Returns
| Type | Description |
|---|---|
| T[] | Instantiated instances from every loadable asset |
Initialize()
Execute setup steps for this AssetSource. It is often unnecessary to call this API directly since all other relevant APIs in this class will Initialize() this AssetSource if it hasn't been already.
Declaration
public void Initialize()
LoadAllRawAssets()
Returns all unprocessed assets that can be loaded from this AssetSource
Declaration
public T[] LoadAllRawAssets()
Returns
| Type | Description |
|---|---|
| T[] | All assets that can be loaded from this AssetSource |
LoadRawAsset(Int32)
Returns the unprocessed asset loaded from the provided index
Declaration
public T LoadRawAsset(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The index of the asset to load |
Returns
| Type | Description |
|---|---|
| T | The asset loaded at the provided index |
ReleaseAssets()
Unloads all assets that have been loaded from this AssetSource
Declaration
public void ReleaseAssets()
SampleAsset()
Returns a uniformly random sampled asset from this AssetSource
Declaration
public T SampleAsset()
Returns
| Type | Description |
|---|---|
| T | The randomly sampled asset |
SampleInstance()
Instantiates and preprocesses a uniformly random sampled asset from this AssetSource
Declaration
public T SampleInstance()
Returns
| Type | Description |
|---|---|
| T | The generated random instance |