{"id":19553133,"url":"https://github.com/needle-tools/unity-type-merger","last_synced_at":"2025-09-13T22:28:25.965Z","repository":{"id":234002761,"uuid":"616092459","full_name":"needle-tools/unity-type-merger","owner":"needle-tools","description":"Merge multiple classes into one using SourceGenerators","archived":false,"fork":false,"pushed_at":"2023-03-26T19:50:45.000Z","size":438,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-24T08:04:51.484Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/needle-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-03-19T15:36:22.000Z","updated_at":"2024-05-19T14:02:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"1ad9693e-f053-4334-8259-ff208bea51a6","html_url":"https://github.com/needle-tools/unity-type-merger","commit_stats":null,"previous_names":["needle-tools/unity-type-merger"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/needle-tools%2Funity-type-merger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/needle-tools%2Funity-type-merger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/needle-tools%2Funity-type-merger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/needle-tools%2Funity-type-merger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/needle-tools","download_url":"https://codeload.github.com/needle-tools/unity-type-merger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251051471,"owners_count":21528787,"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-11-11T04:21:46.458Z","updated_at":"2025-04-26T20:31:56.587Z","avatar_url":"https://github.com/needle-tools.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unity Type Merger\n\nMerge multiple classes into one using SourceGenerators\n\n\u003e ⚠ This is very experimental\n\n## How it works:\n\n1) Mark your class or component as `partial`\n2) Add one or multiple `MergeClass` attributes to your class\n3) Insert a list of type names that you want to be merged into that class or component \n\n\nExample Class:\n```csharp\nnamespace MyNamespace\n{\n\t[MergeClass(\"MyNamespace.MyOtherType\", \"MyNamespace.SomeOtherBehaviour\")]\n\t[MergeClass(\"Partials.SomeThirdType\")]\n\tpublic partial class TestComponent\n\t{\n\t\tpublic string SomeString = \"Hello World\";\n\t}\n}\n\n```\n\nResulting Sourcegen:\n```csharp\nnamespace MyNamespace\n{\n\tpublic partial class TestComponent : MonoBehaviour, IMyInterface // ScriptableObject\n\t{\n\t\t// Begin MyOtherType\n\t\tpublic string HelloWorld = \"test123\";\n\t\tpublic void MyInterfaceMethod()\n\t\t{\n\t\t\t\n\t\t}\n\t\t// End MyOtherType\n\n\t\t// Begin SomeOtherBehaviour\n\t\tpublic bool Active = true;\n\t\tpublic void Update()\n\t\t{\n\t\t\tif (Active)\n\t\t\t\tDebug.Log(\"IT WORKS\");\n\t\t}\n\t\t// End SomeOtherBehaviour\n\n\t\t// Begin SomeThirdType\n\t\tpublic void MySpecialMethod()\n\t\t{\n\t\t\tDebug.Log(\"Hello from some third type\");\n\t\t}\n\t\t// End SomeThirdType\n\n\t}\n}\n```\n\nFinal component:  \n![image](https://user-images.githubusercontent.com/5083203/226190153-589ec52c-6ba7-4693-9c1f-5204c03b87a7.png)\n\n\n## Limitations\n- Multiple base classes are not supported (e.g. for multiple partials deriving from different classes only the first one will be used)\n- If the main class already has a base type and a partial also has a base type it will cause compiler errors (Sourcegen currently doesnt check that)\n- If partials have member name collisions (e.g. two classes declaring a method name `MySpecialMethod` it will cause compiler errors). \n- Types to merge must either be in the same assembly or the script file name must match the C# type name to merge (same as with Unity's components)\n\n\n## Debugging\n- See https://github.com/needle-tools/unity-analyzers-starter#debugging\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneedle-tools%2Funity-type-merger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneedle-tools%2Funity-type-merger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneedle-tools%2Funity-type-merger/lists"}