{"id":13730775,"url":"https://github.com/Siccity/SerializableCallback","last_synced_at":"2025-05-08T03:31:47.363Z","repository":{"id":52671164,"uuid":"115104042","full_name":"Siccity/SerializableCallback","owner":"Siccity","description":"UnityEvent and System.Func had a child","archived":false,"fork":false,"pushed_at":"2024-04-03T18:18:19.000Z","size":46,"stargazers_count":362,"open_issues_count":14,"forks_count":53,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-09T18:03:01.608Z","etag":null,"topics":["callback","serializable","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/Siccity.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-12-22T10:15:22.000Z","updated_at":"2024-10-30T14:31:17.000Z","dependencies_parsed_at":"2024-01-06T15:08:01.244Z","dependency_job_id":"35e82a19-1c68-44c0-8d73-658513b861a7","html_url":"https://github.com/Siccity/SerializableCallback","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siccity%2FSerializableCallback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siccity%2FSerializableCallback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siccity%2FSerializableCallback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Siccity%2FSerializableCallback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Siccity","download_url":"https://codeload.github.com/Siccity/SerializableCallback/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224695703,"owners_count":17354461,"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":["callback","serializable","unity"],"created_at":"2024-08-03T02:01:19.250Z","updated_at":"2024-11-14T21:31:35.238Z","avatar_url":"https://github.com/Siccity.png","language":"C#","readme":"### SerializableCallback\nLets you drag-and-drop methods with or without return values / parameters in the Unity inspector.\nIt uses expression trees and reflection to cache a delegate on first execution.\n\nUsage is identical to UnityEvent\n\n![unity_inspector](https://user-images.githubusercontent.com/6402525/34294989-46de127e-e70b-11e7-84f0-99bc4525a8f5.png)\n```csharp\npublic class MyClass : MonoBehaviour {\n    //These fields are shown in the inspector\n    public SerializableCallback callback; // supports all non-void return types\n    public Condition condition; // supports bool return types only\n    public GetProduct getProduct; // supports MyProduct return types only\n\n    void Start() {\n        // Callbacks can be invoked with or without parameters, and with different types\n        Debug.Log(callback.Invoke()); // returns object\n        Debug.Log(condition.Invoke()); // returns bool\n        Debug.Log(getProduct.Invoke(2)); // returns MyProduct\n    }\n\n    // As with UnityEvents, custom callbacks must have a non-generic wrapper class marked as [Serializable] in order to be serialized by Unity\n    [Serializable]\n    public class Condition : SerializableCallback\u003cbool\u003e {}\n\n    // Last generic type parameter is the return type, staying consistent with System.Func\n    [Serializable]\n    public class GetProduct : SerializableCallback\u003cint, MyProduct\u003e {}\n}\n```\n\n| Performance (100000 iterations)              | Time      |\n| -------------------------------------------- | --------- |\n| bool Method(float)                           | 00.00304s |\n| SerializedCallback\u003cfloat, bool\u003e (Persistent) | 00.01026s |\n| SerializedCallback\u003cfloat, bool\u003e (Dynamic)    | 00.00797s |\n\n\n### Installing with Unity Package Manager\nTo install this project as a dependency using the Unity Package Manager,\nadd the following line to your project's `manifest.json`:\n\n```\n\"com.github.siccity.serializablecallback\": \"git+https://github.com/Siccity/SerializableCallback.git\"\n```\n\nJoin the [Discord](https://discord.gg/qgPrHv4 \"Join Discord server\") server to leave feedback or get support.\n\n\n","funding_links":[],"categories":["Open Source Packages","Open Source Repositories","C#"],"sub_categories":["Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSiccity%2FSerializableCallback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSiccity%2FSerializableCallback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSiccity%2FSerializableCallback/lists"}