You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Provides a base implementation for `INotifyPropertyChanged`, exposing the `PropertyChanged` events
215
215
- Provides a series of `Set` methods that can be used to easily set property values from types inheriting from `ViewModel`, and to automatically raise the appropriate events
216
216
217
+
> **Note:** In case your viewmodel doesn't have a parameterless constructor, you need to override the `GetBindingContext` method on the view.
218
+
217
219
#### Simple property
218
220
219
221
Here's an example of how to implement notification support to a custom property:
@@ -257,8 +259,78 @@ public class UserViewModel : ViewModel
257
259
258
260
### CanvasView\<TBindingContext\>
259
261
262
+
The `CanvasView<TBindingContext>` is a base class for `uGUI` view's.
263
+
264
+
Key functionality:
265
+
- Provides a base implementation for `Canvas` based view
266
+
- Automatically searches for bindable UI elements on the `Canvas`
267
+
- Allows to override the base viewmodel instance creation
268
+
- Allows to define 'property' & 'parameter' value converters
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.
@@ -298,9 +370,9 @@ public class CounterViewModel : ViewModel
@@ -589,14 +698,58 @@ public class ImageViewerView : DocumentView<ImageViewerViewModel>
589
698
590
699
### UniTask
591
700
592
-
#### Async commands
701
+
To enable [async commands](#asynccommand--asynccommandt) support, you need to add the [UniTask](https://github.com/Cysharp/UniTask) package to your project.
593
702
594
-
...
595
-
<!--For IAsyncCommand support, it is required to import com.demigiant.unitask from OpenUPM or-->
703
+
In addition to async commands **UnityMvvmToolkit** provides extensions to make [USS transition's](https://docs.unity3d.com/Manual/UIE-Transitions.html) awaitable.
596
704
597
-
#### Transition async extensions
705
+
For example, your `VisualElement` has the following transitions:
706
+
```css
707
+
.panel--animation {
708
+
transition-property: opacity, padding-bottom;
709
+
transition-duration: 65ms, 150ms;
710
+
}
711
+
```
598
712
599
-
...
713
+
You can `await` these transitions using several methods:
714
+
```csharp
715
+
publicasyncUniTaskDeactivatePanel()
716
+
{
717
+
try
718
+
{
719
+
panel.style.opacity=0;
720
+
panel.style.paddingBottom=0;
721
+
722
+
// Await for the 'opacity' || 'paddingBottom' to end or cancel.
723
+
awaitpanel.WaitForAnyTransitionEnd();
724
+
725
+
// Await for the 'opacity' & 'paddingBottom' to end or cancel.
726
+
awaitpanel.WaitForAllTransitionsEnd();
727
+
728
+
// Await 150ms.
729
+
awaitpanel.WaitForLongestTransitionEnd();
730
+
731
+
// Await 65ms.
732
+
awaitpanel.WaitForTransitionEnd(0);
733
+
734
+
// Await for the 'paddingBottom' to end or cancel.
0 commit comments