Skip to content

Commit 5b06aaa

Browse files
committed
2 parents c85c1f2 + f2beb54 commit 5b06aaa

File tree

1 file changed

+100
-34
lines changed

1 file changed

+100
-34
lines changed

README.md

Lines changed: 100 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
A package that brings data-binding to your Unity project.
44

5+
![git-main](https://user-images.githubusercontent.com/28132516/187478087-909fc50b-778b-4827-8090-c5a66d7b6b11.png)
6+
57
## :open_book: Table of Contents
68

79
- [About](#pencil-about)
8-
- [Restrictions](#restrictions)
910
- [Samples](#samples)
1011
- [Folder Structure](#cactus-folder-structure)
1112
- [Installation](#gear-installation)
13+
- [IL2CPP restriction](#il2cpp-restriction)
1214
- [How To Use](#rocket-how-to-use)
13-
- [Add new icons set](#add-new-icons-set)
1415
- [Custom control]
15-
- [External Assets](#external-assets)
16+
- [External Assets](#cherries-external-assets)
1617
- [UniTask](#unitask)
17-
- [Benchmarks](#benchmarks)
18+
- [Benchmarks](#chart_with_upwards_trend-benchmarks)
1819
- [Contributing](#bookmark_tabs-contributing)
1920
- [Discussions](#discussions)
2021
- [Report a bug](#report-a-bug)
@@ -24,23 +25,20 @@ A package that brings data-binding to your Unity project.
2425

2526
## :pencil: About
2627

27-
The **UnityMvvmToolkit** is designed to accelerate the development of MVVM applications in Unity. Use the samples as a starting point for understanding how to utilize the package.
28-
29-
<!--This repository contains initial samples for how to utilize the package.
30-
31-
It mostly designed for UI Toolkit but you can use it with UGUI as well.-->
32-
33-
It is built around the following principles:
34-
- ...
35-
- ...
36-
- ...
28+
The **UnityMvvmToolkit** is a package that allows you to bind UI elements in your `UI Document` or `Canvas` to data sources in your app. Use the samples as a starting point for understanding how to utilize the package.
3729

38-
### Restrictions
39-
40-
...
30+
#### Key features:
31+
- Runtime data-binding
32+
- UI Toolkit & uGUI integration
33+
- Multiple-properties binding
34+
- Custom UI Elements support
35+
- Compatible with [UniTask](https://github.com/Cysharp/UniTask)
36+
- Mono & IL2CPP support[*](#il2cpp-restriction)
4137

4238
### Samples
4339

40+
The following example shows the **UnityMvvmToolkit** in action using the **Counter** app.
41+
4442
<details open><summary><b>CounterView</b></summary>
4543
<br />
4644

@@ -109,18 +107,20 @@ public class CounterViewModel : ViewModel
109107
<td align="center">ToDoList</td>
110108
</tr>
111109
<tr>
112-
<td align="center">
110+
<td align="center" width=32%>
113111
<video src="https://user-images.githubusercontent.com/28132516/187030099-a440bc89-4c28-44e3-9898-9894eac5bff4.mp4" alt="CounterSample" />
114112
</td>
115-
<td align="center">
116-
<video src="https://user-images.githubusercontent.com/28132516/187030102-2b02c663-31cb-4d63-a764-4be9484359f0.mp4" alt="CalculatorSample" />
113+
<td align="center" width=32%>
114+
<video src="https://user-images.githubusercontent.com/28132516/187471982-4acdeddb-ec4d-45b6-a2a3-4198a03760de.mp4" alt="CalculatorSample" />
117115
</td>
118-
<td align="center">
116+
<td align="center" width=32%>
119117
<video src="https://user-images.githubusercontent.com/28132516/187030101-ad1f2123-59d5-4d1e-a9ca-ab983589e52f.mp4" alt="ToDoListSample" />
120118
</td>
121119
</tr>
122120
</table>
123121

122+
> You will find all the samples in the `samples` folder.
123+
124124
## :cactus: Folder Structure
125125

126126
.
@@ -133,19 +133,17 @@ public class CounterViewModel : ViewModel
133133
├── src
134134
│ ├── UnityMvvmToolkit.Core
135135
│ └── UnityMvvmToolkit.UnityPackage
136+
│ ...
136137
│ ├── Core # Auto-generated
137138
│ ├── Common
138139
│ ├── External
139140
│ ├── UGUI
140-
│ └── UI # UI Toolkit
141+
│ └── UITK
141142
142143
├── UnityMvvmToolkit.sln
143144

144145
## :gear: Installation
145146

146-
Dependencies:
147-
- Unity UnityMvvmToolkit: [UniTask](https://openupm.com/packages/com.cysharp.unitask/)
148-
149147
You can install UnityMvvmToolkit in one of the following ways:
150148

151149
<details><summary>1. Install via Package Manager</summary>
@@ -174,22 +172,61 @@ You can install UnityMvvmToolkit in one of the following ways:
174172
You can add `https://github.com/ChebanovDD/UnityMvvmToolkit.git?path=src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit` to the Package Manager.
175173
176174
If you want to set a target version, UnityMvvmToolkit uses the `v*.*.*` release tag, so you can specify a version like `#v0.1.0`. For example `https://github.com/ChebanovDD/UnityMvvmToolkit.git?path=src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit#v0.1.0`.
177-
178-
> **Note:** Dependencies must be installed before installing the package.
179175
180176
</details>
181177
182-
### [Releases Page](https://github.com/ChebanovDD/UnityMvvmToolkit/releases)
178+
### IL2CPP restriction
183179
184-
- ...
185-
- ...
186-
- ...
180+
The **UnityMvvmToolkit** uses generic virtual methods under the hood to create bindable properties, but `IL2CPP` in `Unity 2021` does not support [Full Generic Sharing](https://blog.unity.com/technology/feature-preview-il2cpp-full-generic-sharing-in-unity-20221-beta) this restriction will be removed in `Unity 2022`.
187181
188-
> **Note:** Dependencies must be installed before installing the packages.
182+
To work around this issue in `Unity 2021` you need to change the `IL2CPP Code Generation` setting in the `Build Settings` window to `Faster (smaller) builds`.
183+
184+
<details><summary>Instruction</summary>
185+
<br />
186+
187+
![build-settings](https://user-images.githubusercontent.com/28132516/187468236-4b455b62-48ef-4e9c-9a3f-83391833c3c0.png)
188+
189+
</details>
189190
190191
## :rocket: How To Use
191192
192-
### Add new icons set
193+
The package contains a collection of standard, self-contained, lightweight types that provide a starting implementation for building apps using the MVVM pattern.
194+
195+
The included types are:
196+
197+
- ViewModel
198+
- CanvasView<TBindingContext>
199+
- DocumentView<TBindingContext>
200+
- Command
201+
- Command\<T\>
202+
- AsyncCommand
203+
- AsyncCommand\<T\>
204+
- AsyncLazyCommand
205+
- AsyncLazyCommand\<T\>
206+
- CommandWrapper
207+
- ICommand
208+
- ICommand\<T\>
209+
- IAsyncCommand
210+
- IAsyncCommand\<T\>
211+
- ICommandWrapper
212+
213+
### ViewModel
214+
215+
The `ViewModel` is a base class for objects that are observable by implementing the INotifyPropertyChanged interface. It can be used as a starting point for all kinds of objects that need to support property change notification.
216+
217+
### CanvasView
218+
219+
### DocumentView
220+
221+
### Command
222+
223+
The `Command` and `Command<T>` are ICommand implementations that can expose a method or delegate to the view. These types act as a way to bind commands between the viewmodel and UI elements.
224+
225+
### Property value converter
226+
227+
### Parameter value converter
228+
229+
### Custom control
193230
194231
...
195232
@@ -208,7 +245,36 @@ You can install UnityMvvmToolkit in one of the following ways:
208245
209246
## :chart_with_upwards_trend: Benchmarks
210247
211-
...
248+
<details><summary>Environment</summary>
249+
<br />
250+
<pre>
251+
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
252+
Intel Core i7-8700 CPU 3.20GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
253+
.NET SDK=5.0.301
254+
[Host] : .NET 5.0.7 (5.0.721.25508), X64 RyuJIT
255+
DefaultJob : .NET 5.0.7 (5.0.721.25508), X64 RyuJIT
256+
</pre>
257+
</details>
258+
259+
#### Set & Get value type (int)
260+
261+
<pre>
262+
| Method | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
263+
|-------------------- |------------:|----------:|----------:|-------:|-------:|------:|------:|----------:|
264+
| DirectPropertyUsage | 0.4904 ns | 0.0364 ns | 0.0358 ns | 1.00 | - | - | - | - |
265+
| UnityMvvmToolkit | 3.4734 ns | 0.0925 ns | 0.0865 ns | 7.13 | - | - | - | - |
266+
| Reflection | 225.5382 ns | 4.4920 ns | 4.8063 ns | 463.38 | 0.0176 | - | - | 112 B |
267+
</pre>
268+
269+
#### Complex binding
270+
271+
<pre>
272+
| Method | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
273+
|----------------- |-----------:|---------:|---------:|------:|-------:|------:|------:|----------:|
274+
| ManualApproach | 209.3 ns | 3.02 ns | 2.35 ns | 1.00 | 0.0458 | - | - | 288 B |
275+
| UnityMvvmToolkit | 418.1 ns | 7.82 ns | 8.04 ns | 2.00 | 0.0458 | - | - | 288 B |
276+
| Reflection | 1,566.4 ns | 31.01 ns | 33.18 ns | 7.46 | 0.0725 | - | - | 464 B |
277+
</pre>
212278
213279
## :bookmark_tabs: Contributing
214280

0 commit comments

Comments
 (0)