1.0.2 • Published 2 years ago

com.codewriter.view-binding v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

View Binding Github license Unity 2020.1 GitHub package.json version openupm

View binding library for unity

How to use?

1. Setup ViewContext

ViewContext contains the data necessary to display current part of the interface.

View Context Preview

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.

Text Applicator Preview

3. Set values from code

Code Preview

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:

Builtin adapters:

Builtin binders:

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.