systemapi-query-main-thread

Iterate Unity DOTS entities on the main thread with SystemAPI.Query.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of writing verbose and error-prone entity iteration code by providing a concise SystemAPI main-thread query pattern with correct read/write intent.

Core Features & Use Cases

  • Main-thread entity iteration: Use source-generated SystemAPI.Query to run per-entity logic on the main thread when you cannot parallelize.
  • Correct component access intent: Declare RefRO for read-only data and RefRW for writable components to avoid false dependencies.
  • Query filtering and safety guidance: Apply WithAll/WithAny/WithNone for matching entities and avoid archetype mutation patterns that can invalidate iterators.

Quick Start

Use the systemapi-query-main-thread skill to generate a main-thread SystemAPI.Query loop that updates component data with RefRW/RefRO and safe filtering for your specific entity set.

Frequently Asked Questions about systemapi-query-main-thread

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

FAQPage Schema
How do I iterate entities on the main thread in Unity DOTS?

To iterate entities on the main thread in Unity DOTS, use SystemAPI.Query with source-generated foreach semantics to apply per-entity logic that requires deterministic ordering or tight main-thread integration.

When should I use RefRW vs RefRO for component access in SystemAPI.Query?

Use RefRO for read-only component access and RefRW for writable components in SystemAPI.Query to declare correct read/write intent, which prevents false dependencies and ensures safe archetype operations.

How do I filter entities using WithAll, WithAny, and WithNone in a main-thread query?

You can filter entities in a main-thread query by applying WithAll, WithAny, and WithNone constraints directly to the SystemAPI.Query pattern to match specific entity sets before iteration.

Why does my SystemAPI.Query loop break during archetype mutation in OnUpdate?

SystemAPI.Query loops break during archetype mutation or rebuilds inside OnUpdate because altering the archetype invalidates the active iterator, requiring you to avoid structural changes during the main-thread foreach iteration.

Can I use SystemAPI.Query for per-entity logic that cannot be parallelized?

Yes, SystemAPI.Query is designed for per-entity logic that must run on the main thread when you cannot parallelize, providing a concise pattern with safe filtering and deterministic ordering.