GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lfeq/UnitySingleton: The best way to implement singleton pattern in Unity.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

41 Commits
41 Commits

Folders and files

NameName
Last commit message
Last commit date
Runtime
Runtime
 
 
Samples~
Samples~
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CHANGELOG.md.meta
CHANGELOG.md.meta
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
CONTRIBUTING.md.meta
CONTRIBUTING.md.meta
 
 
LICENSE
LICENSE
 
 
LICENSE.meta
LICENSE.meta
 
 
README.md
README.md
 
 
README.md.meta
README.md.meta
 
 
Runtime.meta
Runtime.meta
 
 
package.json
package.json
 
 
package.json.meta
package.json.meta
 
 

Repository files navigation

Getting Started Features License Resources Download

Unity Singleton

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

Features

  • 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

Getting Started

This package can be added to your project via Git 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. (🚀 Check out the example GameManager 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!

Usage

Add using 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.

Contribute

Please refer to CONTRIBUTING.md for more information on how to contribute to this project.

Download

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.

Resources

  • 📖 Wikipedia
  • 📖 On the _Preload Scene
  • ▶️ Deep dive into the Singleton Pattern

License

MIT @ Unity Community

Made with ❤️ by Unity Community

About

The best way to implement singleton pattern in Unity.

en.wikipedia.org/wiki/Singleton_pattern

Resources

Readme
License

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.