Runtime Availability
Prepare scene resources that your game will create or use later.
On this page
Pixscape normally knows which resources a scene needs from the objects placed in that scene.
Your game can also create things later, such as a prefab or particle effect. Add those resources to Runtime Availability so Pixscape prepares them when the scene loads.
The important rule is:
If gameplay will create or use a resource later, add it to Runtime Availability before loading the scene.
What to add
Typical examples include:
- a prefab spawned later by gameplay code
- a particle effect used after an impact
- an animation created dynamically
- a sprite that is never placed directly in the scene
- an asset that an existing entity can switch to during gameplay
Resources already used directly by the scene are discovered as part of that scene. Runtime Availability is for the extra resources that are not otherwise present.
Scene-relative by design
Runtime Availability belongs to a scene. A resource can be available in one scene without being prepared for every other scene.
This keeps each scene focused on the resources it actually needs.
Runtime Availability and READY
While a scene is loading, Pixscape prepares the scene and its declared Runtime Availability resources. When the load reaches READY, the scene is active and those resources are ready to use.
Normal gameplay does not silently start loading an undeclared scene resource after READY. If an API needs a resource that was not prepared, it fails instead.
This applies to both blocking and progressive scene loading.
Using available resources
Gameplay code continues to use logical names or IDs:
if (api.assets().contains("coin")) {
api.sprites().spawn("coin", 120f, 64f);
}
Studio and Pixscape handle the exported resource data for the scene.
Prefabs
To spawn a prefab later, make the prefab fragment available to the scene. The resources used by that prefab must also be included as required by the exported project. Runtime Availability is about the whole gameplay resource, not just one image inside it.
Particles
Particle effects created through api.particles() must already be prepared for the scene. Calling spawn(...) during gameplay does not lazily load an undeclared .p file.
Add particle effects created from code to Runtime Availability before loading the scene.
If a resource is missing
Different APIs report unavailable resources with the exception appropriate to that operation. The fix is the same: place the resource in the scene or add it to Runtime Availability, export again, and reload the scene.