Skip to main content
Game DevReviewed Dec 4, 2026

Unity Lifecycle

v1.0.0New

Unsigned, install at your own risk

Unverified

This skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.

Install this skill

No account required. Pick your tool, then copy.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install multi-language-standards-unity-lifecycle

What this does: Protect Unity runtime behavior across callbacks, subscriptions, destroyed objects, and Play Mode sessions. Use for Unity lifecycle, domain reload, callback order, event cleanup, main-thread access, or Play Mode lifetime questions. (triggers: Unity lifecycle, Unity domain reload, Unity callback order, Unity destroyed object, Unity main thread, Unity subscription lifetime)

Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/multi-language-standards-unity-lifecycle/SKILL.md

Setup guide →
0Save

Instructions

Unity Lifecycle and Session State

Priority: P1 (HIGH)

Own the lifetime of Unity static fields and event handlers; do not depend on domain reload.

Callback Order

  • Creation: Awake once per object, then OnEnable; Start before the first Update.
  • Frame: FixedUpdate for physics, Update for frame logic, LateUpdate after Update.
  • Teardown: OnDisable before OnDestroy; scene unload and application quit also destroy objects.
  • Ordering: Use Script Execution Order only when cross-object order is a real contract; otherwise make each object self-contained.

Subscription Lifetime

  • Subscribe in OnEnable; unsubscribe the same handler in OnDisable.
  • Unsubscribe before destroying or pooling the listener; a destroyed listener can remain in a static event.
  • With domain reload disabled, static fields and static event subscribers persist between Play Mode sessions. Cleanup must run on exit or the next session accumulates handlers.
  • With scene reload disabled, Unity still calls OnEnable, OnDisable, and OnDestroy for runtime scripts. Do not assume scene reload is cleaning up for you.

Destroyed-Object Null Semantics

  • Unity overloads == for UnityEngine.Object; a destroyed object can compare equal to null while the managed reference still exists.
  • Use if (target == null) for Unity objects. Do not use ?., ??, is null, or ReferenceEquals as a substitute for Unity's lifetime check.
  • A destroyed listener invoked through a static event can still run its managed method. Remove the subscription; do not rely on a null check alone.

Main-Thread Access

  • Unity API calls belong on the main thread. Do not touch Transform, Rigidbody, scenes, or most UnityEngine objects from a worker.
  • Marshal work by queueing a payload and draining it in Update, or by posting through a main-thread SynchronizationContext.
  • Keep the worker payload plain data; resolve Unity objects on the main thread.

Disabled Domain Reload

  • Reset runtime statics on exit or on entering Play Mode; [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] is the runtime hook for enter-time reset.
  • Do not clear statics between the two sessions of a persistence test; that hides the bug the test is meant to catch.
  • Verify with two actual Play Mode sessions in one Editor process, domain reload disabled, and a fixed scene-reload setting.
  • Raise one event per session and assert the second-session callback delta is exactly one. Add a missing-cleanup control that produces two callbacks in the second session.

Verification

  • Use a Play Mode test or an Editor driver that enters and exits Play Mode twice in one process.
  • Record the Editor version, domain/scene reload settings, event count, callback delta per session, and whether any recompile occurred.
  • A compile-only or Edit Mode-only result does not prove runtime subscription cleanup.

Anti-Patterns

  • No "domain reload will reset it": Static state and handlers persist when domain reload is disabled.
  • No ?. on Unity objects: It bypasses Unity's destroyed-object semantics.
  • No background Unity API: Marshal to the main thread before touching scene objects.
  • No single-session proof: A cleanup claim needs a second Play session.

References

  • Lifecycle, domain reload, and two-session verification
This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →

More from Multi-Language Standards

View source →
typescript-best-practicesWrite idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic.31 installscavemanUltra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.26 installsphp-securityPHP-only security standards for database access, password handling, and input validation. Use when securing PHP apps against SQL injection, XSS, or weak password storage; defer Laravel middleware and security questions in other languages.16 installscommon-security-auditProbe for hardcoded secrets, injection surfaces, unguarded routes, business logic flaws, and platform-specific weaknesses across backend (Node, Go, Java, Python, Rust), frontend (React, Angular, Vue), and mobile (iOS, Android, Flutter) codebases. Use when performing security audits, vulnerability scans, secrets detection, or penetration testing.13 installsandroid-performanceOptimize Android app startup, UI rendering, frame stability, and benchmark performance with Baseline Profiles, Macrobenchmark, and lazy initialization. Use when reducing startup time, diagnosing jank, or measuring rendering; defer Compose state API and test-only questions.10 installsnextjs-architectureStructure Next.js projects with Feature-Sliced Design layers, domain-grouped slices, and strict import hierarchy. Use when organizing features into FSD layers, enforcing slice boundaries, or keeping page.tsx thin.9 installs

More Game Dev skills

Browse category →
godotDevelop, test, build, and deploy Godot 4.x games. Includes GdUnit4 for GDScript unit tests and PlayGodot for game automation and E2E testing. Supports web/desktop exports, CI/CD pipelines, and deployment to Vercel/GitHub Pages/itch.io.12 installsscenario-godot-2dUse when building a 2D game in Godot 4.7: make a platformer or top-down controller that feels right (coyote time, jump buffer, jump height), TileMapLayer and TileSet in code, terrains and autotiles that pick wrong tiles, a dual grid, a camera that jitters or stutters, pixel art that looks blurry or uneven, stretch and integer scaling, 2D lights and shadows, y-sort order wrong, parallax gaps, or importing AI-generated sprites and tilesets from Scenario.3 installsscenario-godot-3d-worldUse when building 3D levels and worlds in Godot 4.7: third-person or FPS controller, player stuck on stairs, spring arm camera clipping, blockout with CSG, GridMap and MeshLibrary, terrain (heightmap, HeightMapShape3D, Terrain3D regions, textures, painting), scattering trees with MultiMesh, streaming a big world, procedural meshes with SurfaceTool, Jolt physics settings, importing GLB or glTF from Blender or AI generators (Scenario, Tripo, Meshy, Hitem3D), import scripts, name suffixes, model facing, collision generation, LODs.2 installsscenario-godot-animationUse when animating characters or scenes in Godot 4.7: AnimationPlayer clips and RESET, AnimationTree state machines and blend spaces built in code, Mixamo or glTF import, loop settings, BoneMap retargeting and shared animation libraries, root motion, foot sliding, foot IK with TwoBoneIK3D or custom SkeletonModifier3D, tweens, SpringArm3D cameras, cutscenes; or when a character T-poses, slides, floats, freezes mid-blend or a transition never fires.1 installsscenario-godot-vfxUse when making or fixing particle effects and game feel in Godot 4.7: GPUParticles3D or GPUParticles2D explosion, fireball projectile with trail, impact, sparks, smoke, shockwave, ribbon trails, sub-emitters, particle collision, color curve does nothing, particles pop out or vanish, effect too heavy on mobile, CPUParticles fallback for Compatibility or web, overdraw, hit-stop, freeze frame, screen shake, juice.1 installsscenario-godot-architectureUse when structuring Godot 4.7 game code: folders, scenes and nodes, signals or an event bus autoload, custom Resources for item data, components (health, hitbox, hurtbox), an inventory, save and load, InputMap and key rebinding for keyboard, mouse and gamepad, GDScript static typing and style, or GDScript vs C#; or when code is spaghetti, a folder scan breaks in the export, a save loads wrong, the gamepad does nothing, or @onready is null.1 installs

Frequently asked questions about unity-lifecycle

What does the unity-lifecycle skill do?

Protect Unity runtime behavior across callbacks, subscriptions, destroyed objects, and Play Mode sessions. Use for Unity lifecycle, domain reload, callback order, event cleanup, main-thread access, or Play Mode lifetime questions. (triggers: Unity lifecycle, Unity domain reload, Unity callback order, Unity destroyed object, Unity main thread, Unity subscription lifetime) It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the unity-lifecycle skill?

Run `npx @skills-hub-ai/cli install multi-language-standards-unity-lifecycle` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/multi-language-standards-unity-lifecycle/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does unity-lifecycle work with?

unity-lifecycle runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the unity-lifecycle skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use unity-lifecycle after installing it?

In Claude Code, type `/multi-language-standards-unity-lifecycle` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the unity-lifecycle skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.

Badge for your README

Show that this skill is on Skills Hub. The badge links back to this page and shows the live install count.

Install on Skills Hub badge preview
Markdown
[![Install on Skills Hub](https://skills-hub.ai/api/badges/skill/multi-language-standards-unity-lifecycle)](https://skills-hub.ai/skills/multi-language-standards-unity-lifecycle)
HTML
<a href="https://skills-hub.ai/skills/multi-language-standards-unity-lifecycle"><img src="https://skills-hub.ai/api/badges/skill/multi-language-standards-unity-lifecycle" alt="Install on Skills Hub"></a>

More options in the badge docs.