cocos_enable_dynamic_atlas
Enable runtime dynamic atlas packing in Cocos Creator to batch small UI frames and runtime-generated sprites that AutoAtlas misses, reducing draw calls.
Instructions
Generate a boot script that enables Cocos 3.8's runtime
dynamic atlas (dynamicAtlasManager.enabled = true).
Complements cocos_create_sprite_atlas — AutoAtlas packs at
BUILD time, DynamicAtlas packs at RUN time. Turning both on
catches small UI frames the AutoAtlas doesn't cover (e.g.
runtime-generated text, sprite frames loaded lazily).
The generated .ts flips the global flag on onLoad; attach
the resulting component to any persistent scene node (typically
a GameManager). Typical flow::
r = cocos_enable_dynamic_atlas(project)
cocos_add_script(scene, gm_node_id, r["uuid_compressed"])Parameters:
rel_path— defaults toDynamicAtlasBooter.tsunderassets/scripts/.max_frame_size— sprite frames larger than this (px) are NOT batched. Engine default 512.class_name— TypeScript class name on the script.
Returns {path, rel_path, uuid_standard, uuid_compressed}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | ||
| rel_path | No | DynamicAtlasBooter.ts | |
| max_frame_size | No | ||
| class_name | No | DynamicAtlasBooter |