com.codewriter.view-binding
v1.0.2
Published
View binding library for Unity
Downloads
1
Readme
View Binding
View binding library for unity
How to use?
1. Setup ViewContext
ViewContext contains the data necessary to display current part of the interface.
2. Add applicators and Binders
Applicators reactively update components (Text, Slider, etc) when data changes in ViewContext. Binders subscribes to events and pass them to ViewContext.
3. Set values from code
using UniMob;
using UnityEngine;
using CodeWriter.ViewBinding;
public class ViewBindingSample : MonoBehaviour
{
public ViewVariableBool soundEnabled;
public ViewVariableBool musicEnabled;
public ViewVariableFloat volume;
public ViewEventVoid onClose;
private void Start()
{
soundEnabled.SetValue(true);
soundEnabled.SetValue(false);
volume.SetValue(0.5f);
onClose.AddListener(() => Debug.Log("Close clicked"));
}
}
Documentation
Builtin variable types:
- Boolean (ViewVariableBool)
- Integer (ViewVariableInt)
- Float (ViewVariableFloat)
- String (ViewVariableString)
Builtin event types:
- Void (ViewEventVoid)
- Boolean (ViewEventBool)
- Integer (ViewEventInt)
- Float (ViewEventFloat)
- String (ViewEventString)
Builtin applicators:
- UnityEvent (Bool, Float, Integer, String)
- GameObject - Activity
- UI Button - Interactable
- UI Image - Fill Amount
- UI InputField - Text
- UI Slider - Value
- UI Text - Text
- UI Toggle - IsOn
Builtin adapters:
Builtin binders:
- UI Button - Click
- UI Toggle - ValueChanged
- UI Slider - ValueChanged
- UI InputField - TextChanged
- UI InputField - EndEdit
How to Install
Minimal Unity Version is 2020.1.
Library distributed as git package (How to install package from git URL)
Git URL: https://github.com/codewriter-packages/View-Binding.git
License
View-Binding is MIT licensed.