From 0d5fac14c6759ca92addb43302a9bc5f1b7ce666 Mon Sep 17 00:00:00 2001 From: ChebanovDD Date: Thu, 15 Jun 2023 12:11:23 +0800 Subject: [PATCH 1/3] Add InitOnAwake virtual property to MonoBehaviourView. --- .../Runtime/Common/MonoBehaviourView.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/MonoBehaviourView.cs b/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/MonoBehaviourView.cs index 80f956c..dd9cb60 100644 --- a/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/MonoBehaviourView.cs +++ b/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/MonoBehaviourView.cs @@ -15,17 +15,22 @@ namespace UnityMvvmToolkit.Common public abstract class MonoBehaviourView : MonoBehaviour, IBindableElement where TBindingContext : class, IBindingContext { - private TBindingContext _createdBindingContext; + private bool _isInitialized; private TBindingContext _bindingContext; private IObjectProvider _objectProvider; + private TBindingContext _createdBindingContext; + + protected virtual bool InitOnAwake => true; public TBindingContext BindingContext => _bindingContext; private void Awake() { - OnInit(); - SetBindingContext(); + if (InitOnAwake) + { + Init(); + } } private void OnDestroy() @@ -34,6 +39,19 @@ private void OnDestroy() OnDispose(); } + protected void Init() + { + if (_isInitialized) + { + throw new InvalidOperationException($"{GetType().Name} already initialized."); + } + + OnInit(); + SetBindingContext(); + + _isInitialized = true; + } + public void SetBindingContext(IBindingContext context, IObjectProvider objectProvider) { if (_bindingContext is not null) From 0f047a5cb810453e374784a04a34b4fe952e380d Mon Sep 17 00:00:00 2001 From: ChebanovDD Date: Thu, 15 Jun 2023 12:11:39 +0800 Subject: [PATCH 2/3] Update packages. --- src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json | 4 ++-- src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json b/src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json index 5103eee..c09151b 100644 --- a/src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json +++ b/src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json @@ -1,9 +1,9 @@ { "dependencies": { "com.cysharp.unitask": "2.3.3", - "com.unity.collab-proxy": "2.0.4", + "com.unity.collab-proxy": "2.0.5", "com.unity.feature.2d": "1.0.0", - "com.unity.ide.rider": "3.0.22", + "com.unity.ide.rider": "3.0.24", "com.unity.ide.visualstudio": "2.0.18", "com.unity.ide.vscode": "1.2.5", "com.unity.test-framework": "1.1.33", diff --git a/src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json b/src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json index b0948e8..33a68f8 100644 --- a/src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json +++ b/src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json @@ -102,7 +102,7 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "2.0.4", + "version": "2.0.5", "depth": 0, "source": "registry", "dependencies": {}, @@ -130,7 +130,7 @@ } }, "com.unity.ide.rider": { - "version": "3.0.22", + "version": "3.0.24", "depth": 0, "source": "registry", "dependencies": { From e6f0159fc2dad628c37d47955c2409ae008991e9 Mon Sep 17 00:00:00 2001 From: ChebanovDD Date: Thu, 15 Jun 2023 12:13:08 +0800 Subject: [PATCH 3/3] Bump package version. --- .../Assets/Plugins/UnityMvvmToolkit/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/package.json b/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/package.json index 1c52547..49d3c67 100644 --- a/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/package.json +++ b/src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/package.json @@ -2,7 +2,7 @@ "name": "com.chebanovdd.unitymvvmtoolkit", "displayName": "Unity MVVM Toolkit", "author": { "name": "ChebanovDD", "url": "https://github.com/ChebanovDD" }, - "version": "1.1.3", + "version": "1.1.4", "unity": "2018.4", "description": "The Unity Mvvm Toolkit allows you to use data binding to establish a connection between the app UI and the data it displays. This is a simple and consistent way to achieve clean separation of business logic from UI.", "keywords": [ "mvvm", "binding", "ui", "toolkit" ],