- Notifications
You must be signed in to change notification settings - Fork69
The best way to implement singleton pattern in Unity.
License
MIT, Unknown licenses found
Licenses found
UnityCommunity/UnitySingleton
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
| Getting Started | Features | License | Resources | Download |
|---|
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
- 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
This package can be added to your project viaGit UPM.To add this package, copy:
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. (:rocket: Check out the exampleGameManager 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!
Addusing UnityCommunity.UnitySingleton; for using the classes.
- Use
Singleton<T>for plain C# classes. - Use
MonoSingleton<T>if you want a Scene-based singleton which is not persistent across scenes. - Use
PersistentMonoSingleton<T>if you want a Global and persistent singleton across scenes.
Please refer toCONTRIBUTING.md for more information on how to contribute to this project.
Run the following command in terminal or command prompt to clone the repository:
git clone https://github.com/UnityCommunity/UnitySingleton.git
Or🔥 Download the master branch as zip.
MIT @Unity Community
Made with ❤️ byUnity Community
About
The best way to implement singleton pattern in Unity.
Topics
Resources
License
MIT, Unknown licenses found
Licenses found
Contributing
Uh oh!
There was an error while loading.Please reload this page.