Class ResourceHandle<T>

Provides a handle to a Resource. The underlying resource may be unloaded at any time, while the handle data remains valid. This means that the resource can be loaded into memory at a later time, and the value of the handle would automatically become available.

The ResourceHandle type is not directly constructible. Instead, use Resources.get to get or create a resource handle for a specific UUID.

Type Parameters

Hierarchy

  • FrameworkObject
    • ResourceHandle

Accessors

  • get isLoaded(): boolean
  • Determines if the referenced resource loaded.

    Returns boolean

  • get uuid(): UUID
  • Returns the UUID of the resource this handle is referencing.

    Returns UUID

  • get value(): T
  • Returns the referenced resource.

    Returns T

    If the resource hasn't been loaded it will be loaded in a blocking call, as if calling Resources.load using default settings.

Methods

  • Returns the loading progress of a resource that's being asynchronously loaded.

    Parameters

    • OptionalincludeDependencies: boolean

      If false the progress will reflect the load progress only for this individual resource. If true the progress will reflect load progress of this resource and all of its dependencies.

    Returns number

    Load progress in range [0...1].

  • Casts the resource handle to a resource handle that holds the specified type.

    Type Parameters

    Parameters

    • type: ClassOf<T>

      The type of resource to cast to.

    Returns ResourceHandle<T>

    Resource handle of the specified type or null.

    If the resource handle is not loaded, the method will return null as no type checking can be performed on unloaded handles.