FRP Singleton
Generic singleton pattern implementation for Unity, supporting both MonoBehaviour and standard C# classes. Prevents multiple instances of the same component and provides static access via the Instance property. Includes Singleton<T> for MonoBehaviour-based singletons and SimpleSingleton<T> for standard classes, simplifying common architectural patterns in game development.
com.fredericrp.singleton 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/fredericrp-singleton.git README Markdown
Copy this to your project's README.md
## Installation
Add **FRP 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/fredericrp-singleton.git
```
[](https://www.pkglnk.dev/pkg/fredericrp-singleton)Used By (8)
README
Generic Singleton
Generic version of singleton for both MonoBehaviour and Standard classes.
Singleton is a development pattern that prevents having multiple instances of the same component in a scene. It allows also any script to access this one wihout requiring a manual link between the two.
This one is a generic Singleton that allows you to inherit from it from your class to access its instance with the static Instance property. There are two singleton:
- Singleton
that inherits from MonoBehaviour - SimpleSingleton
that does not
Usage
Extends the Singleton<T> (for MonoBehaviour singletons) or SimpleSingleton<T> (for standard classes singletons) class from your own classes like this:
public class MyBrandNewClass : Singleton<MyBrandNewClass> {
// ... fields, methods, etc.
}
You can call it from other scripts like this :
MyBrandNewClass.Instance.PublicMethod()
See Transition class for a demo.
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In