singleton-access

Access Unity DOTS singleton components in O(1) time via SystemAPI.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents slow, error-prone ECS lookups by providing a direct way to access a guaranteed single entity or component value in O(1) time.

Core Features & Use Cases

  • Read-only singleton access: Use SystemAPI.GetSingleton<T>() to fetch a copy of the singleton value for safe, non-mutating logic (e.g., reading global game config).
  • Write access when needed: Use SystemAPI.GetSingletonRW<T>() for controlled mutation that correctly marks components dirty for change filtering (e.g., updating a global score or settings state).
  • Entity handle access: Use SystemAPI.GetSingletonEntity<T>() when you need the entity reference itself (e.g., for destroying or adding components elsewhere).
  • Correctness gate: Pair singleton access with state.RequireForUpdate<T>() to avoid runtime exceptions when the singleton entity might not exist yet.

Quick Start

Use a singleton component type with state.RequireForUpdate<YourSingletonComponent>() in OnCreate, then read it in OnUpdate via var value = SystemAPI.GetSingleton<YourSingletonComponent>(); to obtain the global configuration without query overhead.

Frequently Asked Questions about singleton-access

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

FAQPage Schema
How do I access a singleton component in Unity DOTS without iterating queries?

Access singleton components in Unity DOTS by using SystemAPI.GetSingleton<T>() to fetch a copy of the uniquely identified value in O(1) time without query iteration overhead.

What is the difference between GetSingleton and GetSingletonRW in ECS?

GetSingletonRW provides write access to ECS singletons, correctly marking components dirty for change filtering, while GetSingleton only fetches a read-only copy for safe, non-mutating logic.

When do I need RequireForUpdate for singleton access in Unity DOTS?

RequireForUpdate guards singleton access by preventing runtime exceptions when the singleton entity might not exist yet, ensuring the system only updates when the required singleton component is present.

How do I get the entity handle of a singleton in Unity ECS?

Get the entity handle of a singleton in Unity ECS by using SystemAPI.GetSingletonEntity<T>(), which returns the entity reference itself for operations like destroying or adding components.

What's the best way to read global game configuration in Unity DOTS systems?

Reading global game configuration in Unity DOTS is best done with SystemAPI.GetSingleton<T>(), which provides direct O(1) access to stable world-global configuration data without query overhead.