A type-safe event system for Unity, designed to handle events with flexibility, synchronous and asynchronous support, and strict type safety.
The GAOS Event System provides a robust event management solution built specifically for Unity. It seamlessly integrates with Unity's component lifecycle while delivering:
- Type-Safe Events: Interface-based event parameters and return values
- Flexible Event Types: Support for void events, events with parameters, events with return values, or both
- Asynchronous Support: Handle long-running operations with async/await
- Progress Tracking: Monitor event execution and results in real-time
- Priority-Based Execution: Control the order of event handler execution
- ScriptableObject Events: Use ScriptableObject-based events for persistent, inspector-configurable event assets
The package includes a complete ScriptableObject-based event system that provides:
- Persistence: Events that survive scene transitions and play mode changes
- Editor Integration: Configure and assign events through Unity's Inspector
- Event Bridges: Connect SO events to UnityEvents for component interactions
- Zero Dependencies: Create fully decoupled architectures where components have no direct references to each other
// Create a ScriptableObject event in the editor and use it like this:
[SerializeField] private SimpleNotificationEvent notificationEvent;
// Trigger the event
notificationEvent.Raise();
// For events with parameters and return values
var request = new CalculationRequest(valueA, valueB, operation);
var results = await calculationEvent.RaiseAsync(request);The GAOS Event System is automatically registered as a service in your Unity project through the ServiceLocator system. No manual installation is required beyond importing the package:
com.gaos.eventsystem
- com.gaos.servicelocator
- com.unity.nuget.newtonsoft-json
For detailed usage instructions and examples, please refer to the included documentation:
- Quick Start Guide - Get up and running in minutes
- Advanced Topics - In-depth exploration of features
- SOEvent Wrapper - Using ScriptableObject-based events
- API Reference - Complete method and interface reference
The GAOS Event System is accessed through the ServiceLocator:
// Get the event system service
IEventSystem eventSystem = ServiceLocator.GetService<IEventSystem>("EventSystem");From there, you can register, subscribe to, and trigger events. See the documentation for complete examples.
- Always unsubscribe from events when they're no longer needed
- Use strongly-typed interfaces for event parameters and return types
- Follow the
IDataInterfacecontract for all event data - Consider using async/await for long-running operations
- Use priority values thoughtfully to control execution order
- Use ScriptableObject events for cross-scene communication
- Consider using event bridges to decouple component interactions
For a list of changes and version history, see the Changelog.
Package created and maintained by Yu Gao