An open API service indexing awesome lists of open source software.

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 ✨

Awesome Lists containing this project

README

          


https://github.com/AIO-GAME



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");
}

```

## ✨ 贡献者





xinansky


xinansky




Starkappa


Starkappa



## 📢 致谢

- **谢谢您选择我们的扩展包。**
- **如果此软件包对您有所帮助。**
- **请考虑通过添加⭐来表示支持。**