{"id":13663856,"url":"https://github.com/UnityCommunity/UnitySingleton","last_synced_at":"2025-04-25T18:31:30.204Z","repository":{"id":40694096,"uuid":"103733805","full_name":"UnityCommunity/UnitySingleton","owner":"UnityCommunity","description":"The best way to implement singleton pattern in Unity.","archived":false,"fork":false,"pushed_at":"2024-10-26T15:19:24.000Z","size":76,"stargazers_count":457,"open_issues_count":2,"forks_count":61,"subscribers_count":17,"default_branch":"main","last_synced_at":"2024-10-29T17:12:00.771Z","etag":null,"topics":["csharp","csharp-code","csharp-library","csharp-script","design-pattern","design-patterns","singleton","singleton-pattern","singleton-standard","singletonpattern","unity","unity-scripts","unity-tutorial","unity3d"],"latest_commit_sha":null,"homepage":"https://en.wikipedia.org/wiki/Singleton_pattern","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UnityCommunity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-16T07:23:38.000Z","updated_at":"2024-10-28T08:18:50.000Z","dependencies_parsed_at":"2024-01-23T07:26:01.540Z","dependency_job_id":"2007dcf0-6b46-45e0-b66b-eb9a8300e138","html_url":"https://github.com/UnityCommunity/UnitySingleton","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnityCommunity%2FUnitySingleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnityCommunity%2FUnitySingleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnityCommunity%2FUnitySingleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnityCommunity%2FUnitySingleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UnityCommunity","download_url":"https://codeload.github.com/UnityCommunity/UnitySingleton/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224011735,"owners_count":17241000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","csharp-code","csharp-library","csharp-script","design-pattern","design-patterns","singleton","singleton-pattern","singleton-standard","singletonpattern","unity","unity-scripts","unity-tutorial","unity3d"],"created_at":"2024-08-02T05:02:39.089Z","updated_at":"2025-04-25T18:31:30.188Z","avatar_url":"https://github.com/UnityCommunity.png","language":"C#","readme":"| [Getting Started](#getting-started) | [Features](#features) | [License](#license) | [Resources](#resources) | [Download](#download) |\n|-------------------------------------|-----------------------|---------------------|-------------------------|-----------------------|\n\n# Unity Singleton\n\nThe 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.\n\n:book: [Learn More about Singleton pattern](https://en.wikipedia.org/wiki/Singleton_pattern)\n\n## Features\n\n- Works in both Development and Production\n- Instantiates Singleton objects if they aren't available by Lazy Load\n- You can configure fields in the inspector for singleton objects in the preload scene\n\n## Getting Started\n\nThis package can be added to your project via [Git UPM](https://docs.unity3d.com/6000.0/Documentation/Manual/upm-ui-giturl.html).\nTo add this package, copy:\n\n```shell\nhttps://github.com/UnityCommunity/UnitySingleton.git\n```\n\nand 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\".\n\nOnce you have the package installed, you may\n\n- Create your own Singleton classes by extending the Generic [:sparkles: Singleton :sparkles:](Runtime/Scripts/Singleton.cs) class. (:rocket: Check out the example [GameManager](Samples/Scripts/GameManager.cs) in the example [_Preload scene](Samples/Scenes/_Preload.unity).)\n- Attach your singleton classes to a GameManager game object in a _Preload scene of your own.\n- Edit the variables inside the inspector\n- Run the game and enjoy!\n\n## Usage\n\nAdd `using UnityCommunity.UnitySingleton;` for using the classes.\n\n- Use `Singleton\u003cT\u003e` for plain C# classes.\n- Use `MonoSingleton\u003cT\u003e` if you want a Scene-based singleton which is not persistent across scenes.\n- Use `PersistentMonoSingleton\u003cT\u003e` if you want a Global and persistent singleton across scenes.\n\n## Contribute\n\nPlease refer to [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to contribute to this project.\n\n## Download\n\nRun the following command in terminal or command prompt to clone the repository:\n\n```bash\ngit clone https://github.com/UnityCommunity/UnitySingleton.git\n```\n\nOr [:fire: Download the master branch as zip](https://github.com/UnityCommunity/UnitySingleton/archive/master.zip).\n\n## Resources\n\n- [:book: Wikipedia](https://en.wikipedia.org/wiki/Singleton_pattern)\n- [:book: On the _Preload Scene](https://stackoverflow.com/questions/35890932/unity-game-manager-script-works-only-one-time/35891919#35891919)\n- [:arrow_forward: Deep dive into the Singleton Pattern](https://www.youtube.com/watch?v=mpM0C6quQjs)\n\n## License\n\nMIT @ [Unity Community](https://github.com/UnityCommunity)\n\nMade with :heart: by [Unity Community](https://github.com/UnityCommunity)\n","funding_links":[],"categories":["C\\#"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUnityCommunity%2FUnitySingleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUnityCommunity%2FUnitySingleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUnityCommunity%2FUnitySingleton/lists"}