{"id":13663518,"url":"https://github.com/benkeatingsmith/Unity-BasicBind","last_synced_at":"2025-04-25T17:31:14.707Z","repository":{"id":220800441,"uuid":"213050295","full_name":"benkeatingsmith/Unity-BasicBind","owner":"benkeatingsmith","description":"Simple one-way MVVM style data binding for Unity.","archived":false,"fork":false,"pushed_at":"2020-04-16T00:15:28.000Z","size":7743,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-10T20:37:37.637Z","etag":null,"topics":["databinding","mvvm","one-way-binding","ui","unity"],"latest_commit_sha":null,"homepage":null,"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/benkeatingsmith.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}},"created_at":"2019-10-05T18:25:19.000Z","updated_at":"2024-09-12T03:15:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"cdc648ff-f872-47e3-bb63-30f8772c5d3e","html_url":"https://github.com/benkeatingsmith/Unity-BasicBind","commit_stats":null,"previous_names":["benkeatingsmith/unity-basicbind"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeatingsmith%2FUnity-BasicBind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeatingsmith%2FUnity-BasicBind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeatingsmith%2FUnity-BasicBind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benkeatingsmith%2FUnity-BasicBind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benkeatingsmith","download_url":"https://codeload.github.com/benkeatingsmith/Unity-BasicBind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250861987,"owners_count":21499199,"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":["databinding","mvvm","one-way-binding","ui","unity"],"created_at":"2024-08-02T05:02:29.435Z","updated_at":"2025-04-25T17:31:12.830Z","avatar_url":"https://github.com/benkeatingsmith.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# Basic Bind (for Unity)\n\n![](example.gif)\n\n*One-way MVVM style data-binding for Unity.*\n\nBasic Bind is a simple data binding system which enables one-way data binding from observable model data to view components.\n\n\n## Installation\n### Manual Import\n1. Clone or dowload this repository somewhere in your Unity project's `Assets` folder.\n\n## Getting Started\n* Explore the example scene in the `Example` folder.\n  * The scene contains a View Model game object with a ViewModel component. Change the values on the component to observe changes in the scnee.\n  * The scene contains a few sample bindings on single game objects as well as a slightly more complex list example which binds prefab instances to a list of configuration data.\n\n## Usage\nTo get started data-binding, first define a new class which extends `ViewModel`.\nViewModels are Unity MonoBehaviours which should contain several `DataSource` or `DataSourceList` fields.\n\nExample:\n```\npublic class ProfileViewModel : ViewModel\n{\n    public StringDataSource Username;\n    public SpriteDataSource Avatar;\n}\n```\n\nAt runtime, data source values can be accessed via the `Value` property.\n```\nvar viewModel = gameObject.GetComponent\u003cProfileViewModel\u003e();\nviewModel.Username.Value = \"Ben\";\nviewModel.Avatar.Value = someSprite;\n```\n\nTo create a binding between a component and a ViewModel, create a new `DataBinding` component.\nDataBinding should contain `DataSourceReference` fields which allow for the binding and serialization of data-binding links.\nDataBinding classes use the `Setup` method to create bindings.\nYou can use the `[AllowedDataTypes]` attribute to help the inspector filter a ViewModel's data sources by type.\n\nExample:\n```\npublic class TextFieldBinding : DataBinding\n{\n    public Text TextField;\n    [AllowedDataTypes(typeof(string))] public DataSourceReference StringSource;\n\n    protected override void Setup()\n    {\n        Bind(StringSource, OnValueChanged);\n    }\n\n    private void OnValueChanged(object sender, EventArgs eventArgs)\n    {\n        if (StringSource != null \u0026\u0026 StringSource.TryGetValue\u003cstring\u003e(out var value))\n        {\n            if (TextField) TextField.text = value;\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenkeatingsmith%2FUnity-BasicBind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenkeatingsmith%2FUnity-BasicBind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenkeatingsmith%2FUnity-BasicBind/lists"}