{"id":16783072,"url":"https://github.com/favoyang/unity-action-sender","last_synced_at":"2025-09-12T05:34:07.485Z","repository":{"id":112694903,"uuid":"256909641","full_name":"favoyang/unity-action-sender","owner":"favoyang","description":"A type-safe replacement to SendMessage.","archived":false,"fork":false,"pushed_at":"2022-09-10T17:08:29.000Z","size":189,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T22:34:59.180Z","etag":null,"topics":["messaging","openupm","unity","upm"],"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/favoyang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"patreon":"openupm"}},"created_at":"2020-04-19T03:58:03.000Z","updated_at":"2024-09-07T20:16:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"95847ff0-a8c4-4a59-90bc-7bbedc6476e5","html_url":"https://github.com/favoyang/unity-action-sender","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/favoyang/unity-action-sender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favoyang%2Funity-action-sender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favoyang%2Funity-action-sender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favoyang%2Funity-action-sender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favoyang%2Funity-action-sender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/favoyang","download_url":"https://codeload.github.com/favoyang/unity-action-sender/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favoyang%2Funity-action-sender/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274759115,"owners_count":25343872,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["messaging","openupm","unity","upm"],"created_at":"2024-10-13T07:48:54.177Z","updated_at":"2025-09-12T05:34:07.420Z","avatar_url":"https://github.com/favoyang.png","language":"C#","funding_links":["https://patreon.com/openupm"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"180\" src=\"https://raw.githubusercontent.com/favoyang/unity-action-sender/master/Media~/icon-512.png\" alt=\"logo\"\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eUnity Action Sender\u003c/h1\u003e\n\n[![openupm](https://img.shields.io/npm/v/com.littlebigfun.action-sender?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.littlebigfun.action-sender/)\n\nA type-safe replacement to SendMessage.\n\nSendMessage is a known trap for hard to maintain. An alternative way is leveraging interfaces with `GetComponents\u003cT\u003e`. This package consists of a group of extension API to simplify the approach.\n\nNotice that [Unity EventSystems](https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.ExecuteEvents.Execute.html) uses the same approach to support custom message. The major difference is that Unity EventSystems is designed for the UI system, therefore it takes extra efforts to support consume, use, or reset an event (like clicks). While this package API is more accessible and similar to the SendMessage calls. See more discussion in [#1](https://github.com/favoyang/unity-action-sender/issues/1).\n\n## How to Use\n\nDefine an interface for your callbacks.\n\n```\npublic interface IDamageable\n{\n    void Damage(float amount);\n    bool IsAlive();\n}\n```\n\nImplements the interface on your component.\n\n```\npublic class Unit : MonoBehaviour, IDamageable\n{\n    public void Damage(float amount)\n    {\n      // take damage.\n    }\n\n    public bool IsAlive()\n    {\n      // return is alive?\n    }\n}\n```\n\nImport the namespace to send actions.\n\n```\nusing LittleBigFun.ActionSender;\n```\n\nReplace SendMessage with:\n\n```\ngameObject.SendAction\u003cIDamageable\u003e(t =\u003e t.Damage(1.0f));\n```\n\nReplace BroadcastMessage with:\n\n```\ngameObject.BroadcastAction\u003cIDamageable\u003e(t =\u003e t.Damage(1.0f));\n```\n\nReplace SendMessageUpwards with:\n\n```\ngameObject.SendActionUpwards\u003cIDamageable\u003e(t =\u003e t.Damage(1.0f));\n```\n\nTo get result value of actions:\n```\nvar results = gameObject.SendAction\u003cIDamageable, bool\u003e(t =\u003e t.IsAlive());\nvar results = gameObject.BroadcastAction\u003cIDamageable, bool\u003e(t =\u003e t.IsAlive());\nvar results = gameObject.SendActionUpwards\u003cIDamageable, bool\u003e(t =\u003e t.IsAlive());\n```\n\n## Install Package\n\nThe package is available on the [openupm registry](https://openupm.com). It's recommended to install it via [openupm-cli](https://github.com/openupm/openupm-cli).\n\n```\nopenupm add com.littlebigfun.action-sender\n```\n\nOr you can install via [Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html).\n\n## Media\n\nIcons made by [Freepik](https://www.flaticon.com/authors/freepik) from [flaticon.com](http://www.flaticon.com)\n\n----\n\nLicense: see LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavoyang%2Funity-action-sender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffavoyang%2Funity-action-sender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavoyang%2Funity-action-sender/lists"}