{"id":14961063,"url":"https://github.com/vadimskyi/eventmanager","last_synced_at":"2025-10-24T20:30:59.069Z","repository":{"id":146553085,"uuid":"400843465","full_name":"Vadimskyi/EventManager","owner":"Vadimskyi","description":"Non-thread-safe event manager. Use only in single thread environment. Preferably Unity thread.","archived":false,"fork":false,"pushed_at":"2021-09-21T19:20:06.000Z","size":39,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T04:02:12.441Z","etag":null,"topics":["csharp","events","unity","unity3d","upm-package"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vadimskyi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-28T16:48:21.000Z","updated_at":"2024-12-25T20:50:05.000Z","dependencies_parsed_at":"2023-06-05T01:00:10.036Z","dependency_job_id":null,"html_url":"https://github.com/Vadimskyi/EventManager","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":0.5384615384615384,"last_synced_commit":"c321ed377ec83488789dc9ee513059bdb46701b2"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadimskyi%2FEventManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadimskyi%2FEventManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadimskyi%2FEventManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vadimskyi%2FEventManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vadimskyi","download_url":"https://codeload.github.com/Vadimskyi/EventManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238030288,"owners_count":19404859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","events","unity","unity3d","upm-package"],"created_at":"2024-09-24T13:23:44.771Z","updated_at":"2025-10-24T20:30:53.795Z","avatar_url":"https://github.com/Vadimskyi.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event Manager for C# (Unity, .NET, .NET Core)\n[![openupm](https://img.shields.io/npm/v/com.vadimskyi.eventmanager?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.vadimskyi.eventmanager/)\n- Non-thread-safe event manager. Use only in single thread environment. Example: Unity-Engine thread.\n- There are zero dependencies on Unity Engine components. Usage in any kind of c# project should be allowed.\n- Extremely easy to use and faster than most usual approaches\n- For concurrent multithreaded event-system check out this package: TODO\n![Performance comparison graph](https://user-images.githubusercontent.com/1322279/131223932-38d6fbb5-f8c7-449a-9e71-bf8abbfd1bf8.png)\n![Performance comparison graph GC](https://user-images.githubusercontent.com/1322279/131224733-cb2a0ba8-d462-4eaf-918f-a41dc4da4d49.png)\nUnityOfficialSystem: https://learn.unity.com/tutorial/create-a-simple-messaging-system-with-events#5cf5960fedbc2a281acd21fa\n\n## Table of Contents\n\n- [Installation](#installation)\n    - [Unity Package](#unity-package)\n    - [UPM CLI](#upm-cli)\n- [Quick Start](#quick-start)\n- [Main reasoning behind this library](#main-reasoning)\n- [Precaution](#precaution)\n- [Author Info](#author-info)\n\n## Installation\n\nThis library is distributed via Unity's built-in package manager. Required Unity 2018.3 or later.\nSinse Unity's package manager does not support git-url dependencies you should install them manually, if required.\n\n### Unity Package\n- Open Unity project\n- Download and run .unitypackage file from the latest release\n\n### UPM CLI\n- You need to have upm-cli installed: https://github.com/openupm/openupm-cli#openupm-cli\n- Open Git-Bash, CMD, or PowerShell for Windows console\n```console\n# go to the unity project folder\n$ cd ~/Document/projects/hello-openupm\n\n# add package\n$ openupm add com.vadimskyi.eventmanager\n```\n- Open Unity for package to be installed\n\n## Quick Start\n\nDefine the class for your event and derive it from `EventBase\u003cClassName\u003e` abstarct base class.\n\n```csharp\npublic class TestEvent : EventBase\u003cTestEvent\u003e\n{\n}\n```\n\nOptionally, you can also define argument data or pass it directly for the generic argument type.\n\n```csharp\npublic class PlayerMovedEvent : EventBase\u003cPlayerMovedEvent, PlayerMovedData\u003e\n{\n}\n\npublic readonly struct PlayerMovedData\n{\n    public readonly int PlayerId;\n    public readonly Vector3 Position;\n    public PlayerMovedData(int id, Vector3 pos)\n    {\n        PlayerId = id;\n        Position = pos;\n    }\n}\n```\n\nSubscribe to event:\n\n```csharp\npublic class SomeEventListener : MonoBehaviour\n{\n    public void Start()\n    {\n        PlayerMovedEvent.Subscribe(OnPlayerMoved);\n    }\n    \n    public void OnPlayerMoved(PlayerMovedData data) { ... }\n    \n    public void OnDestroyed()\n    {\n        PlayerMovedEvent.Unsubscribe(OnPlayerMoved);\n    }\n}\n```\n\nInvoke event:\n\n```csharp\npublic class Player : MonoBehaviour\n{\n    private int _playerId;\n    \n    public void Update()\n    {\n        if(positionChanged)\n        {\n            PlayerMovedEvent.Invoke(new PlayerMovedData(_playerId, transform.localPosition));\n        }\n    }\n}\n```\n\n## Main reasoning\n\n- Allows communication between components with regards to separations of concerns principle.\n- Light-weight and easy on GC. Allowing it to be used in tight loops and Unity Update cycles.\n- Maintainable and scalable architecture allows this system to be further optimized by using only blittable types for events and/or by managing native pointers instead of events-array.\n\n## Precaution\n\nInternally, this event manager is operating as \"global\" manager. Meaning that every event subscription will be persistent through all application lifecycle, unless unsubscribed manually. This, in fact, makes unsubscription of anonymous delegates problematic.\nMore on this issue: https://stackoverflow.com/questions/25563518/why-cant-i-unsubscribe-from-an-event-using-a-lambda-expression/25564492#25564492\nBottom line is: try not to use anonymous delegates with this [Event Manager] if possible.\n\n## Author Info\n\nVadim Zakrzhewskyi (a.k.a. Vadimskyi) a software developer from Ukraine.\n\n~10 years of experience working with Unity3d, mostly freelance/outsource.\n\n* Twitter: [https://twitter.com/vadimskyi](https://twitter.com/vadimskyi) (English/Russian)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimskyi%2Feventmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvadimskyi%2Feventmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimskyi%2Feventmanager/lists"}