https://github.com/aio-game/unity.notify
✨ Lightweight Notification System ✨
https://github.com/aio-game/unity.notify
event notification unity
Last synced: about 1 year ago
JSON representation
✨ Lightweight Notification System ✨
- Host: GitHub
- URL: https://github.com/aio-game/unity.notify
- Owner: AIO-GAME
- License: mit
- Created: 2024-06-08T01:34:43.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T02:27:57.000Z (over 1 year ago)
- Last Synced: 2025-04-02T09:21:52.519Z (about 1 year ago)
- Topics: event, notification, unity
- Language: C#
- Homepage:
- Size: 784 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: .github/README.md
- Contributing: .github/CONTRIBUTING
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
Unity Notify
English | 简体中文
## ⚙ 安装
Packages Manifest
````json
{
"dependencies": {
"com.aio.notify": "latest"
},
"scopedRegistries": [
{
"name": "package.openupm.com",
"url": "https://package.openupm.com",
"scopes": [
"com.aio.notify"
]
}
]
}
````
Unity PackageManager
> open upm *中国版*
~~~
Name: package.openupm.cn
URL: https://package.openupm.cn
Scope(s): com.aio.notify
~~~
> open upm *国际版*
~~~
Name: package.openupm.com
URL: https://package.openupm.com
Scope(s): com.aio.notify
~~~
Command Line
> open *upm-cli*
~~~
openupm add com.aio.notify
~~~
## ⭐ 关于
- **Unity Notify** 是一个轻量级的事件通知系统,支持事件订阅、广播和取消订阅。
- ✅ **支持** 事件类实现。
- ✅ **支持** 事件参数传递。
- ✅ **支持** 事件参数泛型。
- ✅ **支持** 事件优先级。
- ✅ **支持** 事件订阅。
- ✅ **支持** 事件取消订阅。
- ✅ **支持** 事件广播执行基于协程,不阻塞主线程。
- ✅ **支持** 事件自动注册。
- ✅ **支持** 事件自动取消注册。
- ✅ **支持** 事件自动广播。
- ✅ **支持** 事件自动优先级。
## 📚 使用
初始化
```csharp
EventSystem.Initialize();
```
注册事件
```csharp
EventSystem.AddListener(eid, OnEvent);
EventSystem.AddListener<[T1~T9]>(eid, OnEvent);
```
广播事件
```csharp
EventSystem.Broadcast(eid);
EventSystem.Broadcast(eid, [T1~T9]);
```
注销事件
```csharp
EventSystem.RemoveListener(eid, OnEvent);
EventSystem.RemoveListener<[T1~T9]>(eid, OnEvent);
EventSystem.RemoveListener(eid);
```
自动注册事件
```csharp
public class EventListener1 : EventHandler
{
public override int Key { get; } => 0;
protected override void Invoke() => Console.WriteLine("OnEvent");
}
public class EventListener2 : EventHandler<[T1~T9]>
{
public override int Key { get; } => 0;
protected override void Invoke(<[T1~T9]> args) => Console.WriteLine("OnEvent");
}
```
## ✨ 贡献者
## 📢 致谢
- **谢谢您选择我们的扩展包。**
- **如果此软件包对您有所帮助。**
- **请考虑通过添加⭐来表示支持。**