RSX Code Reference
    Preparing search index...

    Class Resources

    The Resources class provides APIs to dynamically load and unload Resource objects at runtime.

    Hierarchy (View Summary)

    Index
    • Deep-clones a loaded resource, assigns the clone a new UUID, and registers a loaded handle for it. The duplicate is not persisted to a package automatically.

      Parameters

      • resource: Resource

        Loaded resource to duplicate.

      Returns Resource

      The independent duplicate, or null if the input is null or not loaded.

      Thread safe.

    • Checks is the specific animation resource dirty and needs saving.

      Parameters

      Returns boolean

      True if the resource requires saving, false otherwise.

    • Loads a Resource with the specified UUID synchronously. If the resource is already loaded, its existing instance is returned.

      Type Parameters

      Parameters

      • type: ClassOf<T>

        Expected resource type.

      • uuid: UUID

        Unique identifier of the resource to load.

      • Optionalflags: EnumValue<ResourceLoadFlag>

        Optional flags used to control the load process.

      Returns T

      The loaded resource, or null if it cannot be found or does not match type.

      At runtime, the resource and its package must be included in the deployed build.

    • Loads a Resource with the specified UUID asynchronously. If the resource is already loaded, its existing instance is returned.

      Type Parameters

      Parameters

      Returns Promise<T>

      A promise that resolves to the loaded resource.

      At runtime, the resource and its package must be included in the deployed build.

    • Releases an internal reference held by the resource system for the specified Resource or ResourceHandle. This allows a resource loaded with ResourceLoadFlag.KeepInternalRef to be unloaded after all external references are released.

      Parameters

      Returns void

      Call Resources.unloadUnused to release all resources that no longer have external references when fine-grained control is not required.

    • Discards all changes from a resource and re-downloads it from the cloud.

      Parameters

      • resource: Resource

        The resource to be reset and re-downloaded from the cloud.

      Returns AsyncOp<void, void>

      This API is asynchronous and will run in the background.

    • Marks a resource in the current project as clean.

      Parameters

      Returns void

    • Marks a resource in the current project as dirty.

      Parameters

      • resource: Resource

        Resource to mark as dirty.

      • OptionalisDirty: boolean

        Whether the resource is dirty or it should be marked as clean.

      Returns void

    • Checks if the resource should be cloned before queuing a save operation.

      Parameters

      • type: Type

        Type of the resource.

      Returns boolean

      True if the resource should be cloned.

    • Unloads all resources that are no longer referenced.

      Returns void

      This only applies to resources loaded with ResourceLoadFlag.KeepInternalRef flag, as all other resources will be unloaded when they go out of scope.

    • Replaces the object referenced by handle with a deep clone of resourceToClone. All copies of the target handle observe the replacement. The clone keeps the target handle's UUID and owns independent streaming data.

      Parameters

      • handle: Resource | ResourceHandle<Resource>

        Loaded target handle whose referenced object will be replaced.

      • resourceToClone: Resource

        Loaded resource to clone. Its runtime type must match the target resource type.

      Returns void

      Thread safe.

    onResourceDirtyChanged: Event<[resource: Resource, isDirty: boolean]>

    An event fired whenever a resource is marked as dirty.

    onResourceLoaded: Event<[resource: ResourceHandle<Resource>]>

    Triggered after a resource and its requested dependencies finish loading successfully.

    This event will be called from the main thread only.

    onResourceAppear: Event<[packageUUID: UUID, resourceUUID: UUID]>

    Triggered when package metadata makes a resource UUID available for loading.

    This event will be called from the main thread only.

    onResourceDisappear: Event<[packageUUID: UUID, resourceUUID: UUID]>

    Triggered when unloading or updating a package makes a resource UUID unavailable for future loads. An already loaded resource may remain alive until its references are released.

    This event will be called from the main thread only.

    onResourceDestroyed: Event<[resourceUUID: UUID]>

    Triggered after a loaded resource is destroyed and its handle data is cleared.

    It's guaranteed that this event will be called from the main thread.

    onResourceHandleChanged: Event<[resource: ResourceHandle<Resource>]>

    Triggered after the object referenced by an existing handle is replaced. The handle keeps the same UUID.

    It's guaranteed that this event will be called from the main thread.

    onResourceReverted: Event<[resource: ResourceHandle<Resource>]>

    Triggered after a resource handle is reverted to the representation stored in its package.

    It's guaranteed that this event will be called from the main thread.