Resources
Runtime resource loader bound to the current effect.
| Type | Name | Interface Description |
|---|---|---|
| Static Functions | exist(path: string): boolean | • Function: Check whether a resource is available under the given project path. The path is resolved relative to Parameters • Returns |
| Static Functions | getAllPaths(): string[] | • Function: Get every original project path of the resources bundled with the current effect package. Paths are returned in their original casing as authored in the Effect House project. Returns An array of original project paths; empty when no resources are bundled with the current effect. |
| Static Functions | load(path: string): any | • Function: Load a resource by its original project path. The path may be supplied with or without its file suffix; when multiple resources share the same base path, the first match is returned. Supported asset types: - Texture ( Parameters • Returns The loaded resource instance, or |
| Static Functions | loadAll(path: string): any[] | • Function: Load every resource that matches the given project path. When the path is supplied without a file suffix, all resources sharing the same base path are returned, ordered by resource type priority (images first, followed by materials, prefabs and meshes). Supported asset types: - Texture ( Parameters • Returns The loaded resource instances in priority order, or an empty array when the current scene has no active asset manager or the path cannot be resolved to any resource. |
Examples
exist(path: string): boolean
if (APJS.Resources.exist('icon.png')) {
const icon = APJS.Resources.load('icon.png');
// Use the loaded resource...
}
getAllPaths(): string[]
const paths = APJS.Resources.getAllPaths();
for (const path of paths) {
console.log(path);
}
load(path: string): any
// Load a texture using its full path (relative to Assets/resources).
const icon = APJS.Resources.load('icon.png');
// Load by base path (suffix omitted).
const material = APJS.Resources.load('character');
if (icon) {
// Use the loaded resource...
}
loadAll(path: string): any[]
// Load every material variant that shares the same base path.
const materials = APJS.Resources.loadAll('PBR');
// Load a specific material by its full path.
const pbr = APJS.Resources.loadAll('PBR.omtl');
for (const material of materials) {
// Use each loaded material...
}
Use Case
@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
// TODO: instantiate / use Resources here
}
onUpdate(deltaTime: number) {
}
}