{"id":13786213,"url":"https://github.com/GalvanicGames/unity-events","last_synced_at":"2025-05-11T22:30:48.517Z","repository":{"id":215848001,"uuid":"45582893","full_name":"GalvanicGames/unity-events","owner":"GalvanicGames","description":"A code focused strongly typed event system with global system and per GameObject system.","archived":false,"fork":false,"pushed_at":"2019-02-19T17:51:39.000Z","size":206,"stargazers_count":77,"open_issues_count":0,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-17T22:36:13.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GalvanicGames.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-11-05T02:47:21.000Z","updated_at":"2024-09-23T09:34:07.000Z","dependencies_parsed_at":"2024-01-17T05:14:03.024Z","dependency_job_id":"c17dc3bf-af8d-4f27-ac8f-2958218d591e","html_url":"https://github.com/GalvanicGames/unity-events","commit_stats":null,"previous_names":["galvanicgames/unity-events"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GalvanicGames%2Funity-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GalvanicGames%2Funity-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GalvanicGames%2Funity-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GalvanicGames%2Funity-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GalvanicGames","download_url":"https://codeload.github.com/GalvanicGames/unity-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253645098,"owners_count":21941311,"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":[],"created_at":"2024-08-03T19:01:11.773Z","updated_at":"2025-05-11T22:30:47.945Z","avatar_url":"https://github.com/GalvanicGames.png","language":"C#","readme":"# Unity Events 2.0 #\nA performant code focused strongly typed publisher/subscriber event system to decouple objects from talking directly to each other. Supports global event system and per GameObject event systems that send deferred events to be processed at a later tick (FixedUpdate, Update, or LateUpdate). Allows regular callback events and multithreaded jobs that trigger on events.\n\nCustom Event Systems can be created to control when events are processed instead of relying on the update ticks.\n\nUses Unity's new Job System and the burst compiler. Both of those features are considered in preview and experimental. Use at your own risk!\n\n#### Obtain! ####\n[Releases](https://github.com/GalvanicGames/unity-events/releases)\n\nIf you'd like the most up to date version (which is the most cool), then pull the repo or download it [here](https://github.com/GalvanicGames/unity-events/archive/master.zip) and copy the files in Assets to your project's Assets folder.\n\n## Setup\nOnce the Unity Events asset has been imported into the project then the event system is ready to be used.\n\n### Prerequisites ###\nRequires the following Unity packages:\n```\nJobs\nMathematics\nCollections\nBurst\n```\n\nAlso requires:\n```\n.NET 4.x Runtime (Default in 2018.3)\n```\n\n## Examples\nThere are multiple [simple](Assets/UnityEvents/Examples/Simple) and [advanced](Assets/UnityEvents/Examples/Advance) examples in the repository and can be looked at for guidance.\n\nAs a simple example here is how an event can be sent to a Global event system and a GameObject's local event system.\n```csharp\n// I have to be an unmanaged type! Need references? Use an id and have a lookup database system.\nprivate struct EvExampleEvent\n{\n  public int exampleValue;\n\n  public EvExampleEvent(int exampleValue)\n  {\n    this.exampleValue = exampleValue;\n  }\n}\n\n// The callback that will be invoked on an event\nprivate void OnExampleEvent(EvExampleEvent ev)\n{\n  Debug.Log(\"Event received! Value: \" + ev.exampleValue);\n}\n\nprivate void OnEnable()\n{\n  // Subscribes to the global event system, handles events in FixedUpdate\n  GlobalEventSystem.Subscribe\u003cEvExampleEvent\u003e(OnExampleEvent);\n\n  // Subscribes to THIS GameObject's event system! Also Fixed Update\n  gameObject.Subscribe\u003cEvExampleEvent\u003e(OnExampleEvent);\n}\n\npublic void SendEvents()\n{\n  // Send an event to the global event system, will be processed in the next FixedUpdate\n  GlobalEventSystem.SendEvent(new EvExampleEvent(10));\n\n  // Send an event to a specific GameObject, only listeners subscribed to that gameobject will get\n  // this event. Also will be processed in the next FixedUpdate\n  gameObject.SendEvent(new EvExampleEvent(99));\n}\n\n```\n\n## BLITTABLE NOTE!\nUnity Events 2.0 requires that events/jobs are [blittable](https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types) types. This is done to allow compatibility with the burst compiler and Unity's Job system. Also has a benefit of encouraging \"better\" programming practices since the events are deferred. References may become stale and GameObjects may have been destroyed and are \"null\" by the time the event is processed. Send the data the event represents rather than a reference to an object. If a reference is needed then create a look up database and send the id of the object for event listeners to look up to process on. If an array/list is needed then consider using something like [ValueTypeLists](https://gist.github.com/cjddmut/cb43af3ee191af78363f41a3188c0f7b).\n\n## 'DISABLE_EVENT_SAFETY_CHKS' Define Symbol\nUnity Events 2.0 does various safety checks to make sure it isn't being used inappropriately. These can be turned off by defning 'DISABLE_EVENT_SAFETY_CHKS' with the compiler (or in Unity go to 'Player Settings \u003e Scripting Define Symbols'). Turning it off can improve performance since no checks will always be faster than any check. Use at your own risk!\n\n## Dropped Features\nUnity Events 2.0 was rebuilt with performance and flexibility more in mind. Because of this some features of the original version of Unity Events have been dropped. If these features are important than the previous version of Unity Events can be found [here](https://github.com/GalvanicGames/unity-events/releases/tag/1.0).\n","funding_links":[],"categories":["GamePlay","Message Bus"],"sub_categories":["HUD"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGalvanicGames%2Funity-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGalvanicGames%2Funity-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGalvanicGames%2Funity-events/lists"}