https://github.com/bcoffeedev/game-core-architecture-modular-singleton
A lightweight modular initialization framework for Unity.
https://github.com/bcoffeedev/game-core-architecture-modular-singleton
design-patterns framework modular singleton unity unity-package
Last synced: 10 months ago
JSON representation
A lightweight modular initialization framework for Unity.
- Host: GitHub
- URL: https://github.com/bcoffeedev/game-core-architecture-modular-singleton
- Owner: BcoffeeDev
- License: mit
- Created: 2025-06-10T18:39:44.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-14T18:22:25.000Z (10 months ago)
- Last Synced: 2025-06-14T19:38:49.624Z (10 months ago)
- Topics: design-patterns, framework, modular, singleton, unity, unity-package
- Language: C#
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ๐งฑ Modular Singleton Architecture for Unity
A lightweight and extensible modular architecture framework for Unity projects.
This package provides a centralized `BaseContainer` system that manages the lifecycle of self-contained modules derived from `BaseModule`.
## โจ Features
- ๐งฉ **Modular Design** โ Create independent components by inheriting from `BaseModule`.
- ๐ฆ **Centralized Access** โ Retrieve modules via `BaseContainer.Instance.GetModule()`.
- ๐ **Lifecycle Control** โ Built-in initialization flow with callback registration.
- ๐ **Cross-Scene Support** โ Optional `DontDestroyOnLoad` singleton pattern.
- ๐ **Type-Safe Access** โ Generic module resolution without casting.
## ๐ฆ Installation
To install this package in your Unity project using the Unity Package Manager:
1. Open your Unity project.
2. Go to `Window > Package Manager`.
3. Click the `+` button in the top-left corner and select `Add package from Git URL...`
4. Paste the following URL and click `Add`:
```
https://github.com/BcoffeeDev/game-core-architecture-modular-singleton.git
```
Alternatively, you can add it directly to your `manifest.json`:
```json
"dependencies": {
"com.bcoffee-dev.architecture.modular.singleton": "https://github.com/BcoffeeDev/game-core-architecture-modular-singleton.git"
}
```
## ๐ Getting Started
1. Create a container by inheriting from `BaseContainer`, and add it to your scene:
```csharp
public class MyGameContainer : BaseContainer { }
```
2. Implement your own modules by inheriting from `BaseModule`, and add them to the `modules` list in your container (either via the Inspector).
3. Access modules in code:
```csharp
var myModule = MyGameContainer.Instance.GetModule();
myModule.DoSomething();
```
4. Optionally, register a callback to wait for module initialization:
```csharp
MyGameContainer.RegisterInitializeCallback(() => {
Debug.Log("All modules initialized!");
});
```
## ๐งช Use Case
Perfect for:
- Small to mid-sized Unity games or apps
- Prototyping tools or internal systems
- Projects needing clean and maintainable module organization
## ๐ License
MIT License ยฉ 2025 [bcoffee](https://github.com/bcoffee0630)