Assets API
Check scene asset availability and inspect exported image regions.
On this page
Use api.assets() when you need to check whether an asset is available for the current scene or inspect its exported region.
AssetsAPI assets = api.assets();
Find an asset
Look up an asset by its exported name:
if (api.assets().contains("coin")) {
AssetRegionRef coin = api.assets().region("coin");
}
If your gameplay data already stores Pixscape asset IDs, use the ID overloads:
if (api.assets().contains(42)) {
AssetRegionRef coin = api.assets().region(42);
}
Name lookup uses the exported asset name without its directory or file extension and is case-insensitive. For example, items/coin.png can be looked up as coin.
region(...) throws IllegalArgumentException when the asset is not available. Use contains(...) when absence is an expected gameplay case.
Inspect the exported region
AssetRegionRef provides the information commonly needed by gameplay code:
AssetRegionRef coin = api.assets().region("coin");
int assetId = coin.assetId();
String name = coin.name();
float pixelWidth = coin.width();
float pixelHeight = coin.height();
TextureRegion texture = coin.region();
region() returns a defensive TextureRegion snapshot. You can modify the returned TextureRegion without changing Pixscape’s stored region information or future sprite spawns.
Make dynamic assets available
Assets used by gameplay must be available for the current scene. Assets already placed in the scene are included automatically. If code will use an extra asset later, add it to Runtime Availability in Studio before export.
For direct entity creation, use api.sprites(), api.animations(), api.particles(), or api.prefabs().