{"id":29738624,"url":"https://github.com/mrclaus/uniprefabbinder","last_synced_at":"2026-05-15T12:02:44.137Z","repository":{"id":304523330,"uuid":"1018933919","full_name":"MrClaus/UniPrefabBinder","owner":"MrClaus","description":"Library for fast prefab binding. Nice architectural solution through attributes.","archived":false,"fork":false,"pushed_at":"2025-07-21T23:17:02.000Z","size":266,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-08T00:42:53.407Z","etag":null,"topics":["attribute","binding","instantiate","prefab","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/MrClaus.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-13T11:28:11.000Z","updated_at":"2025-07-21T23:17:06.000Z","dependencies_parsed_at":"2025-07-13T17:43:08.915Z","dependency_job_id":"953ae5ca-7398-4d7a-a9a4-831b454a37bd","html_url":"https://github.com/MrClaus/UniPrefabBinder","commit_stats":null,"previous_names":["mrclaus/uniprefabbinder"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/MrClaus/UniPrefabBinder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrClaus%2FUniPrefabBinder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrClaus%2FUniPrefabBinder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrClaus%2FUniPrefabBinder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrClaus%2FUniPrefabBinder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrClaus","download_url":"https://codeload.github.com/MrClaus/UniPrefabBinder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrClaus%2FUniPrefabBinder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33066132,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["attribute","binding","instantiate","prefab","unity"],"created_at":"2025-07-25T19:01:23.555Z","updated_at":"2026-05-15T12:02:44.094Z","avatar_url":"https://github.com/MrClaus.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"UniPrefabBinder\n===\n[![Releases](https://img.shields.io/github/release/MrClaus/UniPrefabBinder.svg)](https://github.com/MrClaus/UniPrefabBinder/releases)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\nLibrary for fast prefab binding. Nice architectural solution through attributes.\nEasily use binding attributes in your own component descriptions to describe the behavior of prefabs on the scene.\n\n## Attributes used:\n* `[ComponentBinding]` - for component binding\n* `[ObjectBinding]` - for GameObject binding\n* `[PrefabPath]` - to describe the path to your prefab, go to the `Resources` folder (with the standard loader), or you can write your own loader by implementing the interface(s) `IResourceLoader`, `IResourceLoaderByTask` and declare it `PrefabBinder.LoaderSet.Add(...)`\n\nImplementing your own loader may be necessary if your resources and prefabs are loaded, for example, via `Addressables`:\n\n```c#\npublic class CustomLoader : IResourceLoader, IResourceLoaderByTask\n{\n    public async UniTask\u003cT\u003e LoadAddressableAsync\u003cT\u003e(string path) where T : Object\n    {\n        ...\n        return result as T;\n    }\n\n    public T LoadAddressable\u003cT\u003e(string path) where T : Object\n    {\n        ...\n        return result as T;\n    }\n\n    // implement IResourceLoader\n    public T Load\u003cT\u003e(string path) where T : Object =\u003e LoadAddressable\u003cT\u003e(path);\n\n    // implement IResourceLoaderByTask\n    public async Task\u003cT\u003e LoadAsync\u003cT\u003e(string path) where T : Object =\u003e await LoadAddressableAsync\u003cT\u003e(path).AsTask();\n}\n```\n\nFurther declaration of the loader in your project should go as follows:\n\n```c#\nvar loader = new CustomLoader();\nPrefabBinder.LoaderSet.Add((IResourceLoader) loader)\n                      .Add((IResourceLoaderByTask) loader);\n```\n\nThe binding fields of your prefab will already be available the first time the `Awake()` method is executed:\n\n```c#\n[PrefabPath(\"UniPrefabBinder/ExamplePrefab\")]\npublic class ExamplePrefabController : MonoBehaviour\n{\n    [ComponentBinding(\"Text\")]\n    private TextMesh _text = null!;\n    \n    [ComponentBinding(\"Sphere\")]\n    private MeshRenderer _sphereMat = null!;\n    \n    [ComponentBinding]\n    private MeshRenderer _quad = null!;\n    \n    [ObjectBinding(\"Sphere\")]\n    private GameObject _sphere = null!;\n\n    [ObjectBinding(\"ExamplePrefabText\")]\n    private GameObject _pfText = null!;\n\n    private float _time;\n\n    private void Awake()\n    {\n        _text.text = \"Binded\";\n        _quad.enabled = false;\n    }\n\n    private void Update()\n    {\n        _time += Time.deltaTime;\n        if (_time \u003e= 1) {\n            _sphere.SetActive(!_sphere.activeSelf);\n            _pfText.SetActive(!_pfText.activeSelf);\n            _sphereMat.material.color = Color.red;\n            _time = 0;\n        }\n    }\n}\n```\n\nThe attribute's brackets indicate the object's name in the prefab hierarchy. If you want to get a component on the root object of the prefab itself, then simply write the attribute's name without brackets, as you can see in the example above.\n\nIf you have objects inside your prefab with other components implemented (which also have binding attributes), they will be automatically bound regardless of whether you access them by attributes or not. This recursive binding gives more freedom in implementing complex components for UI and other objects.\n\nUse the `Instantiate` method of `PrefabBinder` to get the bound component (prefab) into your scene:\n```c#\npublic class ExampleForScene : MonoBehaviour\n{\n    private void Start()\n    {\n        Bind();\n    }\n    \n    private void Bind()\n    {\n        ExamplePrefabController prefab = PrefabBinder.Instantiate\u003cExamplePrefabController\u003e(transform);\n        Debug.Log($\"Binded prefab name={prefab.name}\");\n    }\n\n    private async Task BindAsync()\n    {\n        ExamplePrefabController prefab = await PrefabBinder.InstantiateAsync\u003cExamplePrefabController\u003e(transform);\n        Debug.Log($\"Binded (async) prefab name={prefab.name}\");\n    }\n}\n```\n\nIf you loaded a prefab resource with a custom loader, you can use the `TryBind\u003cT\u003e` extended method on it to get the same binding `T` component of your prefab.\n\n## Install via git URL\nRequires a version of unity that supports path query parameter for git packages (Unity \u003e= 2019.3.4f1, Unity \u003e= 2020.1a21). You can add `https://github.com/MrClaus/UniPrefabBinder.git?path=Assets/UniPrefabBinder/Main` to Package Manager\n\n![image](https://raw.githubusercontent.com/MrClaus/UniPrefabBinder/main/.github/images/upm_install_1.png)\n\n![image](https://raw.githubusercontent.com/MrClaus/UniPrefabBinder/main/.github/images/upm_install_2.png)\n\nor add `\"com.github.mrclaus.uniprefabbinder\": \"https://github.com/MrClaus/UniPrefabBinder.git?path=Assets/UniPrefabBinder/Main\"` to `Packages/manifest.json`.\n\nIf you want to set a target version, UniPrefabBinder uses the `*.*.*` release tag so you can specify a version like `#1.1.1`. For example `https://github.com/MrClaus/UniPrefabBinder.git?path=Assets/UniPrefabBinder/Main#1.1.1`.\n\n## Install via Unity package file (.unitypackage)\nThe Unity package files will also contain `examples` of how to use the library. The package files (.unitypackage) for each version can be found in the [Releases](https://gitHub.com/MrClaus/UniPrefabBinder/releases/) section\n\n![image](https://raw.githubusercontent.com/MrClaus/UniPrefabBinder/main/.github/images/upm_install_3.png)\n\n## Install via OpenUPM\nAdd a new `OpenUPM` registry to the `Package Manager`, and specify the package name with the desired version in `manifest.json`. Package page on the OpenUPM website: [UniPrefabBinder](https://openupm.com/packages/com.github.mrclaus.uniprefabbinder/)\n\n```json\n{\n  \"dependencies\": {\n    ...\n    \"com.github.mrclaus.uniprefabbinder\": \"1.1.1\"\n  },\n  \"scopedRegistries\": [\n    {\n      \"name\": \"package.openupm.com\",\n      \"url\": \"https://package.openupm.com\",\n      \"scopes\": [\n        ...\n        \"com.github.mrclaus.uniprefabbinder\"\n      ]\n    }\n  ]\n}\n```\n\n## License\nThis library is under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrclaus%2Funiprefabbinder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrclaus%2Funiprefabbinder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrclaus%2Funiprefabbinder/lists"}