Simple Singleton
Simple Singleton provides a straightforward singleton pattern implementation for Unity projects distributed as a UPM package. Extend Singleton<T> instead of MonoBehaviour to automatically create and manage singleton instances, enabling global access to your classes with minimal boilerplate. Perfect for managers, services, and other components that should exist only once in your scene.
com.jimthekiwifruit.simplesingleton 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/simplesingleton.git README Markdown
Copy this to your project's README.md
## Installation
Add **Simple Singleton** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/simplesingleton.git
```
[](https://www.pkglnk.dev/pkg/simplesingleton)README
Simple Singleton
A simple singleton implementation for Unity in UPM form for easy addition to projects.
Installation
In your Unity project open Packages/manifest.json and add "com.jimthekiwifruit.simplesingleton": "https://github.com/JimTheKiwifruit/SimpleSingleton", to the top of your dependencies:
{
"dependencies": {
"com.jimthekiwifruit.simplesingleton": "https://github.com/JimTheKiwifruit/SimpleSingleton.git",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.0.8",
"com.unity.ide.vscode": "1.0.7",
...
}
}
You can checkout the full docs on UPM dependancies at https://docs.unity3d.com/Manual/upm-git.html
Usage
Instead of extending from MonoBehaviour, extend from Singelton<ClassName> like this:
using JimTheKiwifruit.Singleton;
public class YourClass : Singleton<YourClass> {
void DoSomething() {
print("Something");
}
}
Now you can access your singleton from anywhere:
void DoStuffWithSingletonClass() {
YourClass.Instance.DoSomething();
}
No comments yet. Be the first!