Search Results for

    Show / Hide Table of Contents

    Class Asset

    Asset objects base class.

    Inheritance
    System.Object
    Object
    Asset
    BinaryAsset
    JsonAssetBase
    Inherited Members
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public abstract class Asset : Object

    Constructors

    Asset()

    Initializes a new instance of the Asset.

    Declaration
    protected Asset()

    Properties

    IsLoaded

    Returns true if asset is loaded, otherwise false.

    Declaration
    [Unmanaged]
    public bool IsLoaded { get; }
    Property Value
    System.Boolean

    IsVirtual

    Determines whether this asset is virtual (generated or temporary, has no storage so it won't be saved).

    Declaration
    [Unmanaged]
    public bool IsVirtual { get; }
    Property Value
    System.Boolean

    LastLoadFailed

    Returns true if last asset loading failed, otherwise false.

    Declaration
    [Unmanaged]
    public bool LastLoadFailed { get; }
    Property Value
    System.Boolean

    MemoryUsage

    Gets amount of CPU memory used by this resource (in bytes). It's a rough estimation. Memory may be fragmented, compressed or sub-allocated so the actual memory pressure from this resource may vary.

    Declaration
    [Unmanaged]
    public ulong MemoryUsage { get; }
    Property Value
    System.UInt64

    Path

    Gets the path to the asset storage file. In Editor, it reflects the actual file, in cooked Game, it fakes the Editor path to be informative for developers.

    Declaration
    [Unmanaged]
    public string Path { get; }
    Property Value
    System.String

    ReferencesCount

    Gets asset's reference count. Asset will be automatically unloaded when this reaches zero.

    Declaration
    [Unmanaged]
    public int ReferencesCount { get; }
    Property Value
    System.Int32

    ShouldDeleteFileOnUnload

    Determines whether this asset was marked to be deleted on unload.

    Declaration
    [Unmanaged]
    public bool ShouldDeleteFileOnUnload { get; }
    Property Value
    System.Boolean

    Methods

    GetReferences()

    Gets the asset references. Supported only in Editor.

    Declaration
    [Unmanaged]
    public Guid[] GetReferences()
    Returns
    System.Guid[]

    The collection of the asset ids referenced by this asset.

    Remarks

    For some asset types (e.g. scene or prefab) it may contain invalid asset ids due to not perfect gather method, which is optimized to perform scan very quickly. Before using those ids perform simple validation via Content cache API. The result collection contains only 1-level-deep references (only direct ones) and is invalid if asset is not loaded. Also, the output data may have duplicated asset ids or even invalid ids (Guid.Empty).

    Reload()

    Reloads the asset.

    Declaration
    [Unmanaged]
    public void Reload()

    Save(String)

    Saves this asset to the file. Supported only in Editor.

    Declaration
    [Unmanaged]
    public bool Save(string path = null)
    Parameters
    System.String path

    The custom asset path to use for the saving. Use empty value to save this asset to its own storage location. Can be used to duplicate asset. Must be specified when saving virtual asset.

    Returns
    System.Boolean

    True when cannot save data, otherwise false.

    ToString()

    Declaration
    public override string ToString()
    Returns
    System.String

    WaitForLoaded(Double)

    Stops the current thread execution and waits until asset will be loaded (loading will fail, success or be cancelled).

    Declaration
    [Unmanaged]
    public bool WaitForLoaded(double timeoutInMilliseconds = 30000)
    Parameters
    System.Double timeoutInMilliseconds

    Custom timeout value in milliseconds.

    Returns
    System.Boolean

    True if cannot load that asset (failed or has been cancelled), otherwise false.

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.RawClone<T>(T)
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat