Skip to content

Latest commit

 

History

History
171 lines (136 loc) · 3.95 KB

README_EN.md

File metadata and controls

171 lines (136 loc) · 3.95 KB

https://github.com/AIO-GAME

Unity Notify

简体中文 | English

⚙ Install

Packages Manifest
{
  "dependencies": {
    "com.aio.notify": "latest"
  },
  "scopedRegistries": [
    {
      "name": "package.openupm.com",
      "url": "https://package.openupm.com",
      "scopes": [
        "com.aio.notify"
      ]
    }
  ]
}
Unity PackageManager

open upm Chinese Version

Name: package.openupm.cn
URL: https://package.openupm.cn
Scope(s): com.aio.notify

open upm International Version

Name: package.openupm.com
URL: https://package.openupm.com
Scope(s): com.aio.notify
Command Line

open upm-cli

openupm add com.aio.notify

⭐ About

  • Unity Notify is a lightweight event notification system that supports event subscription, broadcasting, and unsubscription.
  • Support event class implementation.
  • Support event parameter passing.
  • Support event parameter generics.
  • Support event priority.
  • Support event subscription.
  • Support event unsubscription.
  • Support event broadcast execution based on coroutine, not blocking the main thread.
  • Support event automatic registration.
  • Support event automatic unRegistration.
  • Support event automatic broadcast.
  • Support event automatic priority.

📚 Usage

Initialize

EventSystem.Initialize();

Subscribe event

EventSystem.AddListener(eid, OnEvent);
EventSystem.AddListener<[T1~T9]>(eid, OnEvent);

Broadcast event

EventSystem.Broadcast(eid);
EventSystem.Broadcast(eid, [T1~T9]);

Unsubscribe event

EventSystem.RemoveListener(eid, OnEvent);
EventSystem.RemoveListener<[T1~T9]>(eid, OnEvent);
EventSystem.RemoveListener(eid);

Auto Register Event

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

✨ Contributors

xinansky
xinansky

📢 Thanks

  • If this package is helpful to you.
  • Please consider adding a ⭐ to show your support.
  • It will be a great encouragement for me to continue to improve.