{"id":13663365,"url":"https://github.com/Moolt/UnityEventBridge","last_synced_at":"2025-04-25T13:33:06.606Z","repository":{"id":210783074,"uuid":"169470674","full_name":"Moolt/UnityEventBridge","owner":"Moolt","description":"A tiny plug-in that allows to subscribe to the events of other GameObjects.","archived":false,"fork":false,"pushed_at":"2019-02-06T20:52:56.000Z","size":503,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-10T19:35:48.880Z","etag":null,"topics":["collision","event","subscribe","unity"],"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/Moolt.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}},"created_at":"2019-02-06T20:18:57.000Z","updated_at":"2024-06-28T05:20:34.000Z","dependencies_parsed_at":"2023-12-04T22:52:08.633Z","dependency_job_id":null,"html_url":"https://github.com/Moolt/UnityEventBridge","commit_stats":null,"previous_names":["moolt/unityeventbridge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnityEventBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnityEventBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnityEventBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnityEventBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moolt","download_url":"https://codeload.github.com/Moolt/UnityEventBridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250825195,"owners_count":21493407,"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":["collision","event","subscribe","unity"],"created_at":"2024-08-02T05:02:25.564Z","updated_at":"2025-04-25T13:33:01.550Z","avatar_url":"https://github.com/Moolt.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# Unity Event Bridge\nSometimes you want to react to events happening in another object, e.g. subscribing to an objects `OnCollision` event.\nThis plug-in allows you to do exactly that with little effort.\n\n![](https://raw.githubusercontent.com/Moolt/UnityEventBridge/master/Screenshots/events.png)\n\n## Setup\nIf you want to get a quick overview you should check out the [demo project](https://github.com/Moolt/UnityRuntimePresets/archive/master.zip). \nYou can also download the [package](https://github.com/Moolt/UnityEventBridge/raw/master/EventBridgePackage.unitypackage) containing only the essential scripts.\n\n## Subscribing to events\n\nThe following example shows how to subscribe to the collision events of a cube with a rigidbody.\nWhen it touches or bounces off the ground, a Debug-Message should be printed. The code could look like this:\n\n```csharp\n//Dont forget to include the namespace\nusing EventBridge;\n\npublic class GameController : MonoBehaviour\n{\n    //Any object you want to overve\n    //This can be a Component or a GameObject reference\n    [SerializeField] private Transform _objectToObserve;\n    //The portal to all the events of the referenced object\n    private IComponentEventHandler _eventHandler;\n\n    private void Start()\n    {\n        //First an event handler has to be requested\n        //It will contain all relevant events you may want to subscribe to\n        _eventHandler = _objectToObserve.RequestEventHandlers();\n        //In this example we subscribe to the CollisionEnter and CollisionExit events\n        //The functions are added using the += operator and are called, when the event occurs\n        _eventHandler.CollisionEnter += OnObjectTouchedGround;\n        _eventHandler.CollisionExit += OnObjectBouncedOffGround;\n    }\n\n    private void OnDestroy()\n    {\n        //You should always unsubscribe from the events when the object is destroyed\n        _eventHandler.CollisionEnter -= OnObjectTouchedGround;\n        _eventHandler.CollisionExit -= OnObjectBouncedOffGround;\n    }\n\n    private void OnObjectTouchedGround(Collision collider)\n    {\n        Debug.Log(\"The cube touched the ground.\");\n    }\n\n    private void OnObjectBouncedOffGround(Collision collider)\n    {\n        Debug.Log(\"The cube bounced off the ground.\");\n    }\n}\n```\n\nExecuting the code will result in something like this:\n\n![](https://raw.githubusercontent.com/Moolt/UnityEventBridge/master/Screenshots/screenshot.png)\n\n## How does it work?\n\nCalling ``.RequestEventHandlers();`` on an object will create a new component on this object. This component listens to all available events unity may fire. If an event occurs, the respective `EventHandler`s will fire. The code is pretty straightforward, [you might want to take a look](https://github.com/Moolt/UnityEventBridge/blob/master/Assets/Scripts/EventBridge/ComponentEventHandler.cs).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMoolt%2FUnityEventBridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMoolt%2FUnityEventBridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMoolt%2FUnityEventBridge/lists"}