Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
U

UnitySingleton

> 设计协作
Open source

The best way to implement singleton pattern in Unity.

699 stars0 likes2 views
WebsiteGitHub

About

The best way to implement singleton pattern in Unity.

Getting Started Features License Resources Download

Unity Singleton

The best way to implement singleton pattern in Unity. By using this pattern you will be able to define Global variables and classes and use their methods and properties in Global. This pattern is a must-have for most of the games that made using Unity engine.

Learn More about Singleton pattern

Features

  • Works in both Development and Production
  • Instantiates Singleton objects if they aren't available by Lazy Load
  • You can configure fields in the inspector for singleton objects in the preload scene

Getting Started

This package can be added to your project via Git UPM. To add this package, copy:

bash
https://github.com/UnityCommunity/UnitySingleton.git

and add it as a git package in the Unity Package Manager by clicking on the "+" icon on the top left of the Package Manager Window, and selecting "Install package from git URL".

Once you have the package installed, you may

  • Create your own Singleton classes by extending the Generic ✨ Singleton ✨ class. ( Check out the example GameManager in the example _Preload scene.)
  • Attach your singleton classes to a GameManager game object in a _Preload scene of your own.
  • Edit the variables inside the inspector
  • Run the game and enjoy!

Usage

Add using UnityCommunity.UnitySingleton; for using the classes.

  • Use Singleton for plain C# classes.
  • Use MonoSingleton if you want a Scene-based singleton which is not persistent across scenes.
  • Use PersistentMonoSingleton if you want a Global and persistent singleton across scenes.

Contribute

Please refer to CONTRIBUTING.md for more information on how to contribute to this project.

Download

Run the following command in terminal or command prompt to clone the repository:

bash
git clone https://github.com/UnityCommunity/UnitySingleton.git

Or Download the master branch as zip.

Resources

  • Wikipedia
  • On the _Preload Scene
  • ▶️ Deep dive into the Singleton Pattern

License

MIT @ Unity Community

Made with ❤️ by Unity Community

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#csharpcsharp-codecsharp-librarycsharp-script

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category设计协作
PricingOpen source

> Related tools

F
Figma
协作式界面设计工具
S
sketch-wakatime
Sketch plugin for automatic time tracking and metrics generated from your Sketch usage.
Q
QuickColor
Quickly apply fills from the global or document color palettes to selected elements - 🎨