icleanupcomponentdata-runtime

Preserve ICleanupComponentData after DestroyEntity for resource-safe Unity DOTS cleanup.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill icleanupcomponentdata-runtime
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: icleanupcomponentdata-runtime
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/icleanupcomponentdata-runtime
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill icleanupcomponentdata-runtime

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the problem of releasing external resources when a Unity DOTS entity is destroyed, without losing the ability to detect the destroyed entity.

Core Features & Use Cases

  • Runtime tombstone lifecycle: Keeps an ICleanupComponentData component after DestroyEntity so systems can observe and act on destroyed entities.
  • Correct on-destroy cleanup pattern: Uses a cleanup query that targets destroyed entities via .WithNone<MainComponent>(), releases the associated handle/resources, then removes the cleanup component to finalize true destruction.
  • Resource-safe destruction workflow: Supports scenarios where you must explicitly free GPU buffers, physics bodies, audio instances, spatial index entries, or registry slots at destruction time.

Quick Start

Ask the AI to add an ICleanupComponentData cleanup component to your entities, then create a cleanup system that detects destroyed entities and releases resources before removing the cleanup component.

Frequently Asked Questions about icleanupcomponentdata-runtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely release external resources when destroying a Unity DOTS entity?

To safely release external resources during Unity DOTS entity destruction, preserve an ICleanupComponentData component after calling DestroyEntity. This allows a dedicated cleanup system to detect the destroyed entity, explicitly free handles like GPU buffers or physics objects, and then remove the component to finalize destruction.

What is the tombstone pattern for entity lifecycle management in Unity DOTS?

The tombstone pattern in Unity DOTS uses an ICleanupComponentData component that survives DestroyEntity, keeping the entity observable for cleanup systems. This mechanism ensures external resources such as audio handles, spatial index entries, or registry slots are explicitly released before the entity is truly destroyed.

How do I detect destroyed entities in a cleanup system without processing live ones?

To detect destroyed entities and prevent processing live ones, query for entities using .WithNone<MainComponent>() in your cleanup system. This enforces query correctness by targeting only entities whose primary component is gone, ensuring you handle resource release exclusively for destroyed entities.

What is the correct system lifecycle pattern for resource-safe entity destruction in Unity DOTS?

The correct system lifecycle pattern for resource-safe entity destruction requires three stages: an acquire or setup system, a detection system using WithNone on the main component, and a release system that frees resources and calls RemoveComponent to trigger final destruction.

Why does my Unity DOTS cleanup system process live entities as if they were destroyed?

Your Unity DOTS cleanup system likely processes live entities because the query lacks .WithNone<MainComponent>(). Enforcing this query constraint strictly targets destroyed entities that still retain their ICleanupComponentData component, preventing live entities from entering the resource release logic.

Can I use ICleanupComponentData to free physics bodies and GPU buffers at runtime?

Yes, you can use ICleanupComponentData to free physics bodies, GPU buffers, audio instances, and spatial index entries at runtime. By preserving this component after DestroyEntity, a cleanup system can detect the destroyed entity and execute the explicit release logic required for these external resources.