https://github.com/949886/eventbus
Simple event system implementation like Java EventBus.
https://github.com/949886/eventbus
csharp event-system eventbus unity unity3d
Last synced: about 1 month ago
JSON representation
Simple event system implementation like Java EventBus.
- Host: GitHub
- URL: https://github.com/949886/eventbus
- Owner: 949886
- License: mit
- Created: 2018-11-30T00:11:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-24T06:57:27.000Z (almost 3 years ago)
- Last Synced: 2025-05-19T12:49:03.043Z (about 1 year ago)
- Topics: csharp, event-system, eventbus, unity, unity3d
- Language: C#
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EventBus
Simple implementation just like java EventBus.
``` C#
private void Start()
{
EventBus.Default.Register(this);
}
private void OnDestroy()
{
EventBus.Default.Unregister(this);
}
[Subscribe(ThreadMode.MAIN)]
private void HandleEvent(ShootMessage message)
{
/* do something when shooting on main thread */
}
[Subscribe]
private void HandleEventSync(ShootMessage message)
{
/* do something when shooting in the same thread */
}
[Subscribe(ThreadMode.BACKGROUND)]
private void HandleEventAsync(ShootMessage message)
{
/* do something when shooting on background thread */
}
public void Update()
{
// Trigger event.
EventBus.Default.Post(new ShootMessage(/*args*/));
}
[Subscribe(ThreadMode.BACKGROUND)]
private void HandleEventAsync(ShootMessage message)
{
/* do something when shooting */
}
public void Update()
{
// Triger event.
EventBus.Default.Post(new ShootMessage(/*args*/));
}
```