unity-singleton-pattern

Implement Unity singleton managers with lifecycle control and scene persistence.

Updated Feb 13, 2026
One-click install
npx skills add https://github.com/MuharremTozan/Ohm-Yura --skill unity-singleton-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-singleton-pattern
Source: https://github.com/MuharremTozan/Ohm-Yura/tree/main/.agents/skills/unity-singleton-pattern
Command: npx skills add https://github.com/MuharremTozan/Ohm-Yura --skill unity-singleton-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Unity projects often require global systems (like GameManager, UIManager) that persist across scenes and are easy to reason about. Without a controlled lifecycle, duplicates and inconsistent states arise, leading to hard-to-trace bugs.

Core Features & Use Cases

  • Singleton<T>: standard single instance that destroys duplicates to keep the original.
  • PersistentSingleton<T>: persists across scene loads.
  • RegulatorSingleton<T>: keeps the NEWEST instance by destroying older ones to support hot-swapping.
  • StaticInstance<T>: lightweight global reference without strict duplication enforcement.
  • Use Case: create GameManager as a PersistentSingleton to maintain score and state across scenes, while UIManager can be a simple Singleton for global UI control.

Quick Start

Attach a manager to a Unity GameObject and access it via its Instance property.

Frequently Asked Questions about unity-singleton-pattern

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

FAQPage Schema
How do I create a global Unity manager that persists across scene loads?

To create a global Unity manager that persists across scene loads, you use the PersistentSingleton implementation. This pattern maintains your manager's state and data throughout scene transitions without being destroyed or duplicated.

What is the best way to handle duplicate global managers in Unity?

The best way to handle duplicate global managers in Unity is through strict lifecycle control. The Singleton implementation automatically destroys duplicate instances to keep the original, while RegulatorSingleton destroys older instances to support hot-swapping with the newest manager.

Can I use a lightweight global reference in Unity without strict duplication enforcement?

Yes, you can use a lightweight global reference in Unity without strict duplication enforcement by implementing StaticInstance. It provides accessible global references for your GameObjects without the overhead of destroying duplicate instances.

Why does my Unity singleton have inconsistent states during scene transitions?

Your Unity singleton has inconsistent states during scene transitions because it lacks a controlled lifecycle. Without deterministic startup and correct destruction rules, duplicates arise, leading to hard-to-trace bugs in your core systems.

When do I need a RegulatorSingleton for Unity game development?

You need a RegulatorSingleton for Unity game development when you want to hot-swap managers. It keeps the newest instance by destroying older ones, ensuring your global manager updates dynamically without retaining outdated references.