View binding library for unity
NOTE: To use View Binding library you need to install Tri Inspector - Free and open-source library that improves unity inspector.
ViewContext contains the data necessary to display current part of the interface.
Applicators reactively update components (Text, Slider, etc) when data changes in ViewContext. Binders subscribes to events and pass them to ViewContext.
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"));
}
}
- Boolean (ViewVariableBool)
- Integer (ViewVariableInt)
- Float (ViewVariableFloat)
- String (ViewVariableString)
- Void (ViewEventVoid)
- Boolean (ViewEventBool)
- Integer (ViewEventInt)
- Float (ViewEventFloat)
- String (ViewEventString)
- UnityEvent (Bool, Float, Integer, String)
- GameObject - Activity
- UI CanvasGroup - Alpha
- UI CanvasGroup - Interactable
- UI CanvasGroup - RaycastTarget
- UI CanvasGroup - Visibility
- UI Button - Interactable
- UI Image - Enabled
- UI Image - Fill Amount
- UI InputField - Text
- UI Slider - Value
- UI Text - Text
- UI TextMeshPro - Text
- UI TextMeshPro - Formatted Text
- UI TextMeshPro - Localized Text
- UI Toggle - IsOn
- Bool To String
- Bool To Formatted String
- Formatted Text
- Compare String
- Float Format
- Float Ratio
- Inverse Boolean
- Text Localize
- Time Localize
- UI Button - Click
- UI Toggle - ValueChanged
- UI Slider - ValueChanged
- UI InputField - TextChanged
- UI InputField - EndEdit
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
View-Binding is MIT licensed.