docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AssetSource<T>

    AssetSources are used to load assets from a generically within a Randomizer

    Inheritance
    object
    AssetSource<T>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Perception.Randomization
    Assembly: Unity.Perception.Runtime.dll
    Syntax
    [Serializable]
    public sealed class AssetSource<T> where T : Object
    Type Parameters
    Name Description
    T

    The type of asset to load

    Fields

    assetSourceLocation

    The location to load assets from

    Declaration
    [SerializeReference]
    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
    int

    Methods

    CreateProcessedInstance(int)

    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
    int 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(int)

    Returns the unprocessed asset loaded from the provided index

    Declaration
    public T LoadRawAsset(int index)
    Parameters
    Type Name Description
    int 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

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