singleton-access

Community

Access unique ECS singletons in O(1).

AuthordyCuong03
Version1.0.0
Installs0

System Documentation

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.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: singleton-access
Download link: https://github.com/dyCuong03/unity-agent-team/archive/main.zip#singleton-access

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.