Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

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

Style
Preview
pkglnk installs badge
## 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
```

[![pkglnk](https://www.pkglnk.dev/badge/johnnyhowe-singleton.svg?style=pkglnk)](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)

  1. In Unity, open the Package Manager
    Window > Package Management > Package Manager

  2. Install Package from git URL
    Package Manager > + (in top left) > Install Package from git URL

  3. Paste https://github.com/JohnnyHowe/unity-singleton.git and 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 SingletonMaster script.

  • 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();
	}
}

Comments

No comments yet. Be the first!