Skip to content

Commit d50d1f2

Browse files
authored
Merge pull request #32 from LibraStack/develop
Minor changes.
2 parents dacb116 + e6f0159 commit d50d1f2

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/Common/MonoBehaviourView.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@ namespace UnityMvvmToolkit.Common
1515
public abstract class MonoBehaviourView<TBindingContext> : MonoBehaviour, IBindableElement
1616
where TBindingContext : class, IBindingContext
1717
{
18-
private TBindingContext _createdBindingContext;
18+
private bool _isInitialized;
1919

2020
private TBindingContext _bindingContext;
2121
private IObjectProvider _objectProvider;
2222

23+
private TBindingContext _createdBindingContext;
24+
25+
protected virtual bool InitOnAwake => true;
2326
public TBindingContext BindingContext => _bindingContext;
2427

2528
private void Awake()
2629
{
27-
OnInit();
28-
SetBindingContext();
30+
if (InitOnAwake)
31+
{
32+
Init();
33+
}
2934
}
3035

3136
private void OnDestroy()
@@ -34,6 +39,19 @@ private void OnDestroy()
3439
OnDispose();
3540
}
3641

42+
protected void Init()
43+
{
44+
if (_isInitialized)
45+
{
46+
throw new InvalidOperationException($"{GetType().Name} already initialized.");
47+
}
48+
49+
OnInit();
50+
SetBindingContext();
51+
52+
_isInitialized = true;
53+
}
54+
3755
public void SetBindingContext(IBindingContext context, IObjectProvider objectProvider)
3856
{
3957
if (_bindingContext is not null)

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.chebanovdd.unitymvvmtoolkit",
33
"displayName": "Unity MVVM Toolkit",
44
"author": { "name": "ChebanovDD", "url": "https://github.com/ChebanovDD" },
5-
"version": "1.1.3",
5+
"version": "1.1.4",
66
"unity": "2018.4",
77
"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.",
88
"keywords": [ "mvvm", "binding", "ui", "toolkit" ],

src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"dependencies": {
33
"com.cysharp.unitask": "2.3.3",
4-
"com.unity.collab-proxy": "2.0.4",
4+
"com.unity.collab-proxy": "2.0.5",
55
"com.unity.feature.2d": "1.0.0",
6-
"com.unity.ide.rider": "3.0.22",
6+
"com.unity.ide.rider": "3.0.24",
77
"com.unity.ide.visualstudio": "2.0.18",
88
"com.unity.ide.vscode": "1.2.5",
99
"com.unity.test-framework": "1.1.33",

src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"url": "https://packages.unity.com"
103103
},
104104
"com.unity.collab-proxy": {
105-
"version": "2.0.4",
105+
"version": "2.0.5",
106106
"depth": 0,
107107
"source": "registry",
108108
"dependencies": {},
@@ -130,7 +130,7 @@
130130
}
131131
},
132132
"com.unity.ide.rider": {
133-
"version": "3.0.22",
133+
"version": "3.0.24",
134134
"depth": 0,
135135
"source": "registry",
136136
"dependencies": {

0 commit comments

Comments
 (0)