Awesome
VitalRouter
VitalRouter, is a source-generator powered zero-allocation fast in-memory messaging library for Unity and .NET.
It can declaratively do async handler/async middleware/sequence control, etc., and could serve as a thin framework to promote unidirectional control flow.
In games, or complex GUI application development, patterns such as central event aggregator/message broker/mediator are powerful patterns to organize N:N relationships. Assembling an asynchronous function pipeline can be even more effective.
Features
- Zero allocation message passing
- Thread-safe
- Pub/Sub, Fan-out
- Async / Non-async handlers
- Fast declarative routing pattern
- Naive event handler pattern
- Async interceptor pipelines
- Parallel, queueing, or other sequential control.
- DI friendly. Also support without DI.
- Optional Extensions
- UniTask support
- R3 integration
- MRuby scripting
Documentation
Visit vitalrouter.hadashikick.jp to see the full documentation.
Installation
Unity
- Prerequirements:
- Unity 2022.2+
- This limitation is due to the use of the Incremental Source Generator.
- Unity 2022.2+
- Optional
- Install UniTask >= 2.5.5
- If UniTask is installed,
VITALROUTER_UNITASK_INTEGRATION
flag is turned on and the optimized GC-free code is executed. - See UniTask Integration section for more details.
- If UniTask is installed,
- Install VContainer >= 1.15.1
- For bringing in DI style, VitalRouter supports Integration with VContainer, a fast and lightweight DI container for Unity.
- See DI section for more details.
- Install UniTask >= 2.5.5
Then, add git URL from Package Manager:
https://github.com/hadashiA/VitalRouter.git?path=/src/VitalRouter.Unity/Assets/VitalRouter#1.6.0
.NET
THe following NuGet packages are available.
Package | Latest version |
---|---|
VitalRouter | |
VitalRouter.Extensions.DependencyInjection |
[!NOTE] For Unity, use of the above package is recommended instead of Nuget.
Async interceptor pipeline
Pipelining of async interceptors for published messages is possible. This is a general strong pattern for data exchange.
<img src="./website/docs/assets/diagram_interceptors.svg" alt="Interceptor Diagram" width="50%" />UniTask Integration
UniTask is a fast async/await extension for Unity. VitalRouter actively supports UniTask.
R3 Integration
R3 is the next generation Reactive Extensions implementation in the C# world. It is an excellent alternative to asynchronous streams, but also an excellent alternative to local events.
VitalRouter supports the ability to work with R3.
MRuby scripting?
It is very powerful if the publishing of commands can be controlled by external data.
For example, when implementing a game scenario, most of the time we do not implement everything in C# scripts. It is common to express large amounts of text data, branching, flag management, etc. in a simple scripting language or data format.
VitalRouter offers an optional package for this purpose before integrating mruby. (blog / blog (Japanease)
Fiber in mruby and async/await in C# are fully integrated.
LISENCE
MIT
AUTHOR
@hadashiA