PlayCanvas script lifecycle
Makes script dependencies and cleanup explicit instead of relying on accidental loading order. It handles enable, disable, cloning and destruction so timers and event handlers follow the entity that owns them.
playcanvas-scripts-lifecycle
See how it helpsWhen is it useful?
Use when repeated entity creation leaves listeners or late callbacks behind.
What does it help you do?
- Checks ESM or classic APIs and registered script names.
- Declares imports and references rather than incidental loading order.
- Assigns listener, timer and asynchronous-work ownership to lifecycle hooks.
Try asking this
Our enemy spawner doubles its output whenever a room is reopened. Trace its script dependencies, subscriptions and timer ownership. Disable, enable, clone and destroy the room; each active spawner should run once, and destroyed rooms must stop reacting to delayed work.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
PlayCanvas — scripts lifecycle
Use when implementing PlayCanvas entity scripts, initialization order, enable/disable or destruction.
Version and project gate
Inspect Engine version, Engine-only versus hosted Editor workflow, ESM versus classic scripts, build/export process, asset IDs and tags, render backend, script attributes and target browser requirements. Do not assume a paid Editor service is required for Engine-only work. Never turn a task into an engine upgrade without the user’s intent. Read the version-matching official reference when an API decision depends on it.
Work
Identify ESM or classic script APIs and registered script names. Declare dependencies through imports and explicit entity references rather than incidental asset loading order. Define initialize/post-initialize/update and disable/destroy ownership for listeners, timers and asynchronous work.
Deliver
A script dependency/lifecycle map and restart-safe implementation. Keep the change in the existing project structure; separate actual observations from the proposed acceptance scenario below.
Failure to prevent
Script loading order is not the same as component method execution order; a file name need not equal the registered script name.
Acceptance scenario
Enable, disable, clone and destroy an entity repeatedly while checking one active listener and no late callback writes. Follow the project’s execution and verification permissions. If execution or a target device is unavailable, provide the reproduction steps and name the remaining uncertainty; do not mark it passed.
Scope and sources
This skill belongs to Cyra. Agent selection is restricted by Orqestria’s assigned-agent policy, including forced skill selection; instruction text alone is not an access control. These are original task workflows researched from official documentation, not a copied or endorsed vendor skill.
- https://developer.playcanvas.com/user-manual/editor/scripting/loading-order/
- https://developer.playcanvas.com/user-manual/assets/loading-unloading/
- https://developer.playcanvas.com/user-manual/optimization/guidelines/
Task-specific official references
Included files 1
SKILL.md
