ModularSingleton
This package provides a centralized ModuleContainer system that manages the lifecycle of self-contained BaseModule components. It supports type-safe module access, optional singleton persistence across scenes, and a unified initialization callback system—ideal for organizing logic in small to mid-sized Unity projects.
com.bcoffee-dev.architecture.modular.singleton 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/bcoffeedev-singleton.git README Markdown
Copy this to your project's README.md
## Installation
Add **ModularSingleton** 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/bcoffeedev-singleton.git
```
[](https://www.pkglnk.dev/pkg/bcoffeedev-singleton)README
🧱 Modular Singleton Architecture for Unity
A lightweight and extensible modular architecture framework for Unity projects.
This package provides a centralized BaseContainer<T> 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<T>.Instance.GetModule<M>(). - 🔁 Lifecycle Control – Built-in initialization flow with callback registration.
- 🌐 Cross-Scene Support – Optional
DontDestroyOnLoadsingleton pattern. - 🔍 Type-Safe Access – Generic module resolution without casting.
📦 Installation
To install this package in your Unity project using the Unity Package Manager:
- Open your Unity project.
- Go to
Window > Package Manager. - Click the
+button in the top-left corner and selectAdd package from Git URL... - 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:
"dependencies": {
"com.bcoffee-dev.architecture.modular.singleton": "https://github.com/BcoffeeDev/game-core-architecture-modular-singleton.git"
}
🚀 Getting Started
- Create a container by inheriting from
BaseContainer<T>, and add it to your scene:
public class MyGameContainer : BaseContainer<MyGameContainer> { }
- Implement your own modules by inheriting from
BaseModule, and add them to themoduleslist in your container (either via the Inspector). - Access modules in code:
var myModule = MyGameContainer.Instance.GetModule<MyCustomModule>();
myModule.DoSomething();
- Optionally, register a callback to wait for module initialization:
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
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In