Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shlifedev/event-flow
non gc game event broadcast system for unity.
https://github.com/shlifedev/event-flow
event-system unity unity-event unity-event-system
Last synced: 26 days ago
JSON representation
non gc game event broadcast system for unity.
- Host: GitHub
- URL: https://github.com/shlifedev/event-flow
- Owner: shlifedev
- Created: 2024-05-13T08:07:25.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-06T07:00:47.000Z (about 2 months ago)
- Last Synced: 2024-11-06T07:37:21.080Z (about 2 months ago)
- Topics: event-system, unity, unity-event, unity-event-system
- Language: ShaderLab
- Homepage:
- Size: 11.1 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# EventFlow
A very easy to use zero-gc game event sending/listen system.
- This is useful for decoupling UI code from game code.
- You can listen to any event that happens in your game where it inherits from IEventListener<>.
- Sending/receiving events does not incur any unnecessary GC. (struct only)
## Requirement
- UniTask## [Example](https://github.com/shlifedev/event-flow/tree/main/src/Assets/Example)
[Movie_001.webm](https://github.com/user-attachments/assets/19ef0dd3-7288-49fa-b3c3-87b2195be071)
## How to use
### [Declare Your Game Event](https://github.com/shlifedev/event-flow/tree/main/src/Assets/Example/Scripts/Messages/OnEntityDamagedMessage.cs)
Just inherit the IEventMessage to the structure.```
public struct YourEvent : IEventMessage{
public string Message;
}
```### [Inherit IEventListenr And Regist](https://github.com/shlifedev/event-flow/tree/main/src/Assets/Example/Scripts/HealthBarUI.cs)
```cs
public class YourClass : MonoBehaviour, IEventListener{
void OnEnable(){
EventFlow.Register(this);
}
void OnDestroy(){
EventFlow.UnRegister(this);
}public UniTask OnEvent(YourMessage args){
Debug.Log("Received! => " + args.Message);
}
}
```### [Broadcast message](https://github.com/shlifedev/unity-event-system/blob/main/GameEvent/Example/Scripts/GameEntity.cs)
```cs
EventBus.Broadcast(new YourMessage(){Message="hi"});
```