Systems Management
Create MonoBehaviour singletons for game systems management with serializable fields and full access to Unity's lifecycle. Eliminates the need for initialization scenes while providing a centralized way to manage persistent systems across your project.
com.jonathonoh.unity.singleton 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/johnnyhowe-singleton.git README Markdown
Copy this to your project's README.md
## Installation
Add **Systems Management** 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/johnnyhowe-singleton.git
```
[](https://www.pkglnk.dev/pkg/johnnyhowe-singleton)README
Before using this or any other singleton implementation please consider whether it is right for your project. Singletons have a lot of drawbacks.
Overview
Create MonoBehaviour singletons.
- Serialize fields and accessing them in the inspector
- Hook into Unity's loop (
Update,FixedUpdate, etc) - No more initialization scene!
Install (UPM)
In Unity, open the Package Manager
Window > Package Management > Package ManagerInstall Package from git URL
Package Manager > + (in top left) > Install Package from git URLPaste
https://github.com/JohnnyHowe/unity-singleton.gitand press Install
(Recommended) If you want a specific version, use https://github.com/JohnnyHowe/unity-singleton.git#<version>
Usage
Create Your Class
public class ExampleSingleton: Singleton<ExampleSingleton>
{
/// AwakeSystem is called similarly to MonoBehaviour.Awake.
/// This is where you put your startup/initialization
protected override void Initialize() { }
public void DoSomething() { }
}
Create Game Systems Prefab
Just one of these in the project.
Each individual Singleton will live as a child of this.
Add the
SingletonMasterscript.Place this in some resource folder.
Add Your System to the Prefab
Create a child object and put your Singleton script on it.
Access it From Anywhere
public class ThingThatUsesExampleGameSystem
{
public void CallDoSomething()
{
ExampleGameSystem.Instance.DoSomething();
}
}
No comments yet. Be the first!