├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Assets ├── Scenes.meta ├── Scenes │ ├── SampleScene.unity │ └── SampleScene.unity.meta ├── Unity-MVVM.meta └── Unity-MVVM │ ├── Editor.meta │ ├── Editor │ ├── BindingMonitorEditorWindow.cs │ ├── BindingMonitorEditorWindow.cs.meta │ ├── CollectionItemBindingEditor.cs │ ├── CollectionItemBindingEditor.cs.meta │ ├── CollectionViewEditor.cs │ ├── CollectionViewEditor.cs.meta │ ├── CollectionViewSourceEditor.cs │ ├── CollectionViewSourceEditor.cs.meta │ ├── DataBindingBaseEditor.cs │ ├── DataBindingBaseEditor.cs.meta │ ├── DataBindingEditor.cs │ ├── DataBindingEditor.cs.meta │ ├── DataBoundActivatorEditor.cs │ ├── DataBoundActivatorEditor.cs.meta │ ├── EventBindingEditor.cs │ ├── EventBindingEditor.cs.meta │ ├── EventPropertyBindingEditor.cs │ ├── EventPropertyBindingEditor.cs.meta │ ├── GUIStyles.cs │ ├── GUIStyles.cs.meta │ ├── GUIUtils.cs │ ├── GUIUtils.cs.meta │ ├── MVVMBaseEditor.cs │ ├── MVVMBaseEditor.cs.meta │ ├── OneWayDataBindingEditor.cs │ ├── OneWayDataBindingEditor.cs.meta │ ├── PackageUpdater.cs │ ├── PackageUpdater.cs.meta │ ├── SerializedList.cs │ ├── SerializedList.cs.meta │ ├── TwoWayDataBindingEditor.cs │ ├── TwoWayDataBindingEditor.cs.meta │ ├── Unity-MVVM.Editor.asmdef │ ├── Unity-MVVM.Editor.asmdef.meta │ ├── UpdateComponentsEditorWindow.cs │ └── UpdateComponentsEditorWindow.cs.meta │ ├── LICENSE │ ├── LICENSE.meta │ ├── Resources.meta │ ├── Samples.meta │ ├── Samples │ ├── AssemblyTest.meta │ ├── AssemblyTest │ │ ├── AssemblyTestScene.unity │ │ ├── AssemblyTestScene.unity.meta │ │ ├── AssemblyViewModel.cs │ │ ├── AssemblyViewModel.cs.meta │ │ ├── TestAssembly.asmdef │ │ └── TestAssembly.asmdef.meta │ ├── Basic Usage.meta │ ├── Basic Usage │ │ ├── CanvasView.unity │ │ ├── CanvasView.unity.meta │ │ ├── DataBinding.unity │ │ ├── DataBinding.unity.meta │ │ ├── DataBindings.meta │ │ ├── DataBindings │ │ │ ├── Converters.meta │ │ │ ├── Converters │ │ │ │ ├── BoolToColorConverter.cs │ │ │ │ └── BoolToColorConverter.cs.meta │ │ │ ├── ViewModel.cs │ │ │ └── ViewModel.cs.meta │ │ ├── Events.unity │ │ ├── Events.unity.meta │ │ ├── Views.meta │ │ └── Views │ │ │ ├── UsingViewsViewModel.cs │ │ │ ├── UsingViewsViewModel.cs.meta │ │ │ ├── ViewModel.cs │ │ │ └── ViewModel.cs.meta │ ├── MVVMTest.meta │ ├── MVVMTest │ │ ├── MVVMTest.unity │ │ ├── MVVMTest.unity.meta │ │ ├── Prefabs.meta │ │ ├── Prefabs │ │ │ ├── TextPrefab.prefab │ │ │ └── TextPrefab.prefab.meta │ │ ├── Scripts.meta │ │ ├── Scripts │ │ │ ├── Converters.meta │ │ │ ├── Converters │ │ │ │ ├── ColorToTextConverter.cs │ │ │ │ ├── ColorToTextConverter.cs.meta │ │ │ │ ├── IntToColorConverter.cs │ │ │ │ ├── IntToColorConverter.cs.meta │ │ │ │ ├── StateToVisibilityConverter.cs │ │ │ │ └── StateToVisibilityConverter.cs.meta │ │ │ ├── TestViewModel.cs │ │ │ ├── TestViewModel.cs.meta │ │ │ ├── TextItem.cs │ │ │ ├── TextItem.cs.meta │ │ │ ├── TwoWayBoolTest.cs │ │ │ └── TwoWayBoolTest.cs.meta │ │ ├── TextItemModel.cs │ │ └── TextItemModel.cs.meta │ ├── PropertyPaths.meta │ ├── PropertyPaths │ │ ├── PropertyPaths.unity │ │ ├── PropertyPaths.unity.meta │ │ ├── PropertyPathsViewModel.cs │ │ └── PropertyPathsViewModel.cs.meta │ ├── SelectableCollectionView.meta │ ├── SelectableCollectionView │ │ ├── ButtoModel.cs │ │ ├── ButtoModel.cs.meta │ │ ├── ButtonItem.cs │ │ ├── ButtonItem.cs.meta │ │ ├── ButtonPrefab.prefab │ │ ├── ButtonPrefab.prefab.meta │ │ ├── OtherViewModel.cs │ │ ├── OtherViewModel.cs.meta │ │ ├── SelectableCollectionView.unity │ │ └── SelectableCollectionView.unity.meta │ ├── Viewstates.unity │ └── Viewstates.unity.meta │ ├── Scripts.meta │ ├── Scripts │ ├── Binding.meta │ ├── Binding │ │ ├── BindTarget.cs │ │ ├── BindTarget.cs.meta │ │ ├── BindingMonitor.cs │ │ ├── BindingMonitor.cs.meta │ │ ├── CollectionItemBinding.cs │ │ ├── CollectionItemBinding.cs.meta │ │ ├── CollectionViewItemBase.cs │ │ ├── CollectionViewItemBase.cs.meta │ │ ├── CollectionViewSource.cs │ │ ├── CollectionViewSource.cs.meta │ │ ├── Converters.meta │ │ ├── Converters │ │ │ ├── BoolToColorConverter.cs │ │ │ ├── BoolToColorConverter.cs.meta │ │ │ ├── BoolToNotBoolConverter.cs │ │ │ ├── BoolToNotBoolConverter.cs.meta │ │ │ ├── BoolToVisibilityConverter.cs │ │ │ ├── BoolToVisibilityConverter.cs.meta │ │ │ ├── ComparisonToBoolConverter.cs │ │ │ ├── ComparisonToBoolConverter.cs.meta │ │ │ ├── ComparisonToVisibilityConverter.cs │ │ │ ├── ComparisonToVisibilityConverter.cs.meta │ │ │ ├── EnumToBoolConverter.cs │ │ │ ├── EnumToBoolConverter.cs.meta │ │ │ ├── EnumToColorConverter.cs │ │ │ ├── EnumToColorConverter.cs.meta │ │ │ ├── EnumToVisibilityConverter.cs │ │ │ ├── EnumToVisibilityConverter.cs.meta │ │ │ ├── FlagToBoolConverter.cs │ │ │ ├── FlagToBoolConverter.cs.meta │ │ │ ├── FlagToVisibilityConverter.cs │ │ │ ├── FlagToVisibilityConverter.cs.meta │ │ │ ├── FormatStringConverter.cs │ │ │ ├── FormatStringConverter.cs.meta │ │ │ ├── IValueConverter.cs │ │ │ ├── IValueConverter.cs.meta │ │ │ ├── RemapValueConverter.cs │ │ │ ├── RemapValueConverter.cs.meta │ │ │ ├── StringToBoolConverter.cs │ │ │ ├── StringToBoolConverter.cs.meta │ │ │ ├── StringToEnumConverter.cs │ │ │ ├── StringToEnumConverter.cs.meta │ │ │ ├── TextTransformationConverter.cs │ │ │ ├── TextTransformationConverter.cs.meta │ │ │ ├── ValueConverterBase.cs │ │ │ └── ValueConverterBase.cs.meta │ │ ├── DataBinding.cs │ │ ├── DataBinding.cs.meta │ │ ├── DataBindingBase.cs │ │ ├── DataBindingBase.cs.meta │ │ ├── DataBindingConnection.cs │ │ ├── DataBindingConnection.cs.meta │ │ ├── DataBoundActivator.cs │ │ ├── DataBoundActivator.cs.meta │ │ ├── EventBinding.cs │ │ ├── EventBinding.cs.meta │ │ ├── EventPropertyBinding.cs │ │ ├── EventPropertyBinding.cs.meta │ │ ├── ICollectionViewItem.cs │ │ ├── ICollectionViewItem.cs.meta │ │ ├── IDataBinding.cs │ │ ├── IDataBinding.cs.meta │ │ ├── OneWayDataBinding.cs │ │ ├── OneWayDataBinding.cs.meta │ │ ├── TwoWayDataBinding.cs │ │ ├── TwoWayDataBinding.cs.meta │ │ ├── VisibilityBinding.cs │ │ └── VisibilityBinding.cs.meta │ ├── Enums.meta │ ├── Enums │ │ ├── BindingMode.cs │ │ └── BindingMode.cs.meta │ ├── Extensions.meta │ ├── Extensions │ │ ├── ComponentExtensions.cs │ │ ├── ComponentExtensions.cs.meta │ │ ├── MemberInfoExt.cs │ │ ├── MemberInfoExt.cs.meta │ │ ├── PropertyInfoExtensions.cs │ │ ├── PropertyInfoExtensions.cs.meta │ │ ├── SerializedPropertyExtensions.cs │ │ ├── SerializedPropertyExtensions.cs.meta │ │ ├── TypeExtensions.cs │ │ └── TypeExtensions.cs.meta │ ├── Model.meta │ ├── Model │ │ ├── IModel.cs │ │ ├── IModel.cs.meta │ │ ├── ModelBase.cs │ │ └── ModelBase.cs.meta │ ├── Types.meta │ ├── Types │ │ ├── EventArgType.cs │ │ ├── EventArgType.cs.meta │ │ ├── MVVMBase.cs │ │ └── MVVMBase.cs.meta │ ├── Unity-MVVM.Runtime.asmdef │ ├── Unity-MVVM.Runtime.asmdef.meta │ ├── Util.meta │ ├── Util │ │ ├── AnimationDispatcher.cs │ │ ├── AnimationDispatcher.cs.meta │ │ ├── ObservableRangeCollection.cs │ │ ├── ObservableRangeCollection.cs.meta │ │ ├── Singleton.cs │ │ ├── Singleton.cs.meta │ │ ├── UnityEventBinder.cs │ │ ├── UnityEventBinder.cs.meta │ │ ├── UserAssemblyConfig.cs │ │ ├── UserAssemblyConfig.cs.meta │ │ ├── ViewModelProvider.cs │ │ └── ViewModelProvider.cs.meta │ ├── View.meta │ ├── View │ │ ├── AnimationDefaults.cs │ │ ├── AnimationDefaults.cs.meta │ │ ├── CanvasView.cs │ │ ├── CanvasView.cs.meta │ │ ├── CollectionViewBase.cs │ │ ├── CollectionViewBase.cs.meta │ │ ├── ISelectable.cs │ │ ├── ISelectable.cs.meta │ │ ├── IView.cs │ │ ├── IView.cs.meta │ │ ├── MultiClickButton.cs │ │ ├── MultiClickButton.cs.meta │ │ ├── ToggleControl.cs │ │ ├── ToggleControl.cs.meta │ │ ├── ViewBase.cs │ │ ├── ViewBase.cs.meta │ │ ├── Visibility.cs │ │ └── Visibility.cs.meta │ ├── ViewModel.meta │ └── ViewModel │ │ ├── IViewModel.cs │ │ ├── IViewModel.cs.meta │ │ ├── ViewModelBase.cs │ │ └── ViewModelBase.cs.meta │ ├── VS.meta │ ├── VS │ ├── bindprop.snippet │ └── bindprop.snippet.meta │ ├── package.json │ └── package.json.meta ├── ChangeLog.md ├── Docs ├── Architechture.md ├── BindingMonitor.md ├── Bindings.md ├── Converters.md ├── Events.md ├── Images │ └── BindingMonitor.jpg ├── ViewModels.md └── Views.md ├── LICENSE ├── Logs └── Packages-Update.log ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset └── XRSettings.asset ├── README.md └── package.json /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | split-upm: 8 | name: split upm branch 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | fetch-depth: 0 14 | - name: split upm branch 15 | run: | 16 | git branch -d upm &> /dev/null || echo upm branch not found 17 | git subtree split -P "$PKG_ROOT" -b upm 18 | git checkout upm 19 | if [[ -d "Samples" ]]; then 20 | git mv Samples Samples~ 21 | rm -f Samples.meta 22 | git config --global user.name 'github-bot' 23 | git config --global user.email 'github-bot@users.noreply.github.com' 24 | git commit -am "fix: Samples => Samples~" 25 | fi 26 | git push -f -u origin upm 27 | env: 28 | PKG_ROOT: Assets/Unity-MVVM 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | [Ll]ogs/ 7 | [Uu]ser[Ss]ettings/ 8 | Assets/AssetStoreTools* 9 | 10 | /[Mm]emoryCaptures/ 11 | 12 | # Visual Studio cache directory 13 | .vs/ 14 | 15 | # Autogenerated VS/MD/Consulo solution and project files 16 | ExportedObj/ 17 | .consulo/ 18 | *.csproj 19 | *.unityproj 20 | *.sln 21 | *.suo 22 | *.tmp 23 | *.user 24 | *.userprefs 25 | *.pidb 26 | *.booproj 27 | *.svd 28 | *.pdb 29 | *.opendb 30 | 31 | # Unity3D generated meta files 32 | *.pidb.meta 33 | *.pdb.meta 34 | 35 | # Unity3D Generated File On Crash Reports 36 | sysinfo.txt 37 | 38 | # Builds 39 | *.apk 40 | *.unitypackage 41 | 42 | # Crashlytics generated file 43 | crashlytics-build.properties 44 | 45 | # Packed Addressables 46 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 47 | 48 | # Temporary auto-generated Android Assets 49 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 50 | /[Aa]ssets/[Ss]treamingAssets/aa/* 51 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf200fa7df266d441b69e8e2be98e74e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 339ef276e40eab34181a05143a49ee75 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aa40108fe7de474c8ae9da504a912d5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a03902b3a0742b45bc0e7fe31351dd0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/BindingMonitorEditorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb67285252296ca46b6a8d00054c328c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/CollectionItemBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 955059e034b4af6449c2cb9004994204 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/CollectionViewEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | using UnityMVVM.Binding; 7 | using UnityMVVM.Util; 8 | using UnityMVVM.View; 9 | 10 | namespace UnityMVVM.Editor 11 | { 12 | [CustomEditor(typeof(CollectionViewBase), true)] 13 | public class CollectionViewEditor : MVVMBaseEditor 14 | { 15 | SerializedProperty _srcCollectionProp; 16 | SerializedList _selectedItemNames = new SerializedList("SelectedItemName"); 17 | SerializedList _selectedItemCollectionNames = new SerializedList("SelectedItemsName"); 18 | SerializedProperty _canSelectMultipleProp; 19 | SerializedProperty _listItemPrefabProp; 20 | 21 | protected override void CollectSerializedProperties() 22 | { 23 | 24 | _selectedItemNames.Init(serializedObject); 25 | _selectedItemCollectionNames.Init(serializedObject); 26 | 27 | _srcCollectionProp = serializedObject.FindProperty("_src"); 28 | _canSelectMultipleProp = serializedObject.FindProperty("CanSelectMultiple"); 29 | _listItemPrefabProp = serializedObject.FindProperty("_listItemPrefab"); 30 | } 31 | 32 | protected override void DrawChangeableElements() 33 | { 34 | GUIUtils.ObjectField("Source Collection", _srcCollectionProp, typeof(CollectionViewSource)); 35 | GUIUtils.ObjectField("List Item Prefab", _listItemPrefabProp, typeof(GameObject)); 36 | //GUIUtils.ToggleField("Can Select Multiple", _canSelectMultipleProp); 37 | if (_canSelectMultipleProp.boolValue) 38 | GUIUtils.BindingField("Selected Item List", _selectedItemCollectionNames); 39 | else 40 | GUIUtils.BindingField("Selected Item", _selectedItemNames); 41 | } 42 | 43 | protected override void UpdateSerializedProperties() 44 | { 45 | _selectedItemNames.UpdateProperty(); 46 | _selectedItemCollectionNames.UpdateProperty(); 47 | } 48 | protected override void SetupDropdownIndices() 49 | { 50 | _selectedItemNames.SetupIndex(); 51 | _selectedItemCollectionNames.SetupIndex(); 52 | } 53 | 54 | protected override void CollectPropertyLists() 55 | { 56 | var myClass = target as CollectionViewBase; 57 | 58 | _selectedItemNames.Clear(); 59 | _selectedItemCollectionNames.Clear(); 60 | 61 | var collectionName = myClass.SrcCollectionName; 62 | if (!string.IsNullOrEmpty(collectionName)) 63 | { 64 | var list = new List(); 65 | 66 | var listType = ViewModelProvider 67 | .GetViewModelType(myClass.ViewModelName) 68 | .GetProperty(collectionName) 69 | .PropertyType 70 | .GenericTypeArguments 71 | .FirstOrDefault(); 72 | 73 | var listCollectionType = typeof(ObservableCollection<>) 74 | .MakeGenericType(listType); 75 | 76 | 77 | list.Add("--"); 78 | list.AddRange(ViewModelProvider.GetViewModelPropertyList(myClass.ViewModelName, 79 | _canSelectMultipleProp.boolValue ? listCollectionType : listType)); 80 | 81 | if (_canSelectMultipleProp.boolValue) 82 | _selectedItemCollectionNames.Values = list; 83 | else 84 | _selectedItemNames.Values = list; 85 | } 86 | } 87 | 88 | public override void OnInspectorGUI() 89 | { 90 | base.OnInspectorGUI(); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/CollectionViewEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79abdb0e9a2b79245b959a73efdc6208 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/CollectionViewSourceEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using UnityEditor; 3 | using UnityMVVM.Binding; 4 | using UnityMVVM.Util; 5 | 6 | namespace UnityMVVM.Editor 7 | { 8 | [CustomEditor(typeof(CollectionViewSource), true)] 9 | public class CollectionViewSourceEditor : DataBindingBaseEditor 10 | { 11 | SerializedList _srcCollectionNames = new SerializedList("SrcCollectionName"); 12 | //SerializedList _selectedItemNames = new SerializedList("SelectedItemName"); 13 | //SerializedList _selectedItemCollectionNames = new SerializedList("SelectedItemsName"); 14 | //SerializedProperty _canSelectMultipleProp; 15 | 16 | protected override void CollectSerializedProperties() 17 | { 18 | base.CollectSerializedProperties(); 19 | 20 | _srcCollectionNames.Init(serializedObject); 21 | } 22 | 23 | protected override void DrawChangeableElements() 24 | { 25 | base.DrawChangeableElements(); 26 | GUIUtils.BindingField("Source Collection", _srcCollectionNames); 27 | 28 | } 29 | 30 | protected override void UpdateSerializedProperties() 31 | { 32 | base.UpdateSerializedProperties(); 33 | 34 | _srcCollectionNames.UpdateProperty(); 35 | } 36 | 37 | protected override void SetupDropdownIndices() 38 | { 39 | base.SetupDropdownIndices(); 40 | 41 | _srcCollectionNames.SetupIndex(); 42 | } 43 | 44 | protected override void CollectPropertyLists() 45 | { 46 | base.CollectPropertyLists(); 47 | 48 | if (_viewModelChanged) 49 | { 50 | _srcCollectionNames.Value = null; 51 | 52 | } 53 | 54 | _srcCollectionNames.Clear(); 55 | 56 | 57 | _srcCollectionNames.Values 58 | = ViewModelProvider.GetViewModelPropertyList(_viewModelProp.Value); 59 | 60 | 61 | 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/CollectionViewSourceEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02f30fd7703c7ab4aac843f5a4917b78 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/DataBindingBaseEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | using UnityMVVM.Binding; 4 | using UnityMVVM.Util; 5 | 6 | namespace UnityMVVM.Editor 7 | { 8 | [CustomEditor(typeof(DataBindingBase), true)] 9 | public class DataBindingBaseEditor : MVVMBaseEditor 10 | { 11 | public string ViewModelName { get => _viewModelProp.Value; } 12 | 13 | public int _viewModelIdx = 0; 14 | protected List _viewModels = new List(); 15 | 16 | protected SerializedList _viewModelProp = new SerializedList("ViewModelName"); 17 | 18 | protected bool _viewModelChanged { get; set; } 19 | 20 | protected override void OnEnable() 21 | { 22 | _viewModels = ViewModelProvider.Viewmodels; 23 | 24 | CollectSerializedProperties(); 25 | 26 | CollectPropertyLists(); 27 | 28 | serializedObject.ApplyModifiedProperties(); 29 | 30 | UpdateSerializedProperties(); 31 | } 32 | 33 | protected override void CollectSerializedProperties() 34 | { 35 | _viewModelProp.Init(serializedObject); 36 | } 37 | 38 | protected void DrawViewModelDrawer() 39 | { 40 | if (string.IsNullOrEmpty(_viewModelProp.Value)) 41 | GUIUtils.Message("No ViewModels. Maybe you should make one!", MessageType.Error); 42 | else 43 | _viewModelChanged = GUIUtils.ViewModelField(_viewModelProp); 44 | } 45 | 46 | protected override void DrawChangeableElements() 47 | { 48 | DrawViewModelDrawer(); 49 | } 50 | 51 | protected override void UpdateSerializedProperties() 52 | { 53 | _viewModelProp.UpdateProperty(); 54 | } 55 | 56 | protected override void SetupDropdownIndices() 57 | { 58 | _viewModelProp.SetupIndex(); 59 | } 60 | 61 | public override void OnInspectorGUI() 62 | { 63 | base.OnInspectorGUI(); 64 | _viewModelChanged = false; 65 | 66 | } 67 | 68 | protected override void CollectPropertyLists() 69 | { 70 | _viewModelProp.Values = ViewModelProvider.Viewmodels; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/DataBindingBaseEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0c743652db1203408e579710f6cbe52 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/DataBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f9a736a6f476f747ab3354c790ff02d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/DataBoundActivatorEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityMVVM.Binding; 6 | using UnityMVVM.Binding.Converters; 7 | 8 | namespace UnityMVVM.Editor 9 | { 10 | [CanEditMultipleObjects] 11 | [CustomEditor(typeof(DataBoundActivator), true)] 12 | public class DataBoundActivatorEditor : OneWayDataBindingEditor 13 | { 14 | SerializedProperty _invertProp; 15 | 16 | protected override void CollectSerializedProperties() 17 | { 18 | base.CollectSerializedProperties(); 19 | 20 | _invertProp = serializedObject.FindProperty("Invert"); 21 | } 22 | 23 | protected override void DrawChangeableElements() 24 | { 25 | DrawViewModelDrawer(); 26 | 27 | GUIUtils.ObjectField("Converter", _converterProp, typeof(ValueConverterBase)); 28 | GUIUtils.BindingField("Source Property", _srcNames, _srcPaths); 29 | 30 | GUIUtils.ToggleField("Invert", _invertProp); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/DataBoundActivatorEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e55f2be5fde0b02468a88b39612e42e9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/EventBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityMVVM.Binding; 6 | using UnityMVVM.Extensions; 7 | using UnityMVVM.Util; 8 | 9 | 10 | namespace UnityMVVM.Editor 11 | { 12 | [CanEditMultipleObjects] 13 | [CustomEditor(typeof(EventBinding), true)] 14 | public class EventBindingEditor : DataBindingBaseEditor 15 | { 16 | SerializedList _eventNames = new SerializedList("SrcEventName"); 17 | SerializedList _methodNames = new SerializedList("DstMethodName"); 18 | 19 | SerializedProperty _srcViewProp; 20 | 21 | protected override void DrawChangeableElements() 22 | { 23 | base.DrawChangeableElements(); 24 | 25 | GUIUtils.BindingField("Destination Method", _methodNames); 26 | GUIUtils.ObjectField("Source View", _srcViewProp, typeof(Component)); 27 | GUIUtils.BindingField("Source Event", _eventNames); 28 | } 29 | 30 | protected override void SetupDropdownIndices() 31 | { 32 | base.SetupDropdownIndices(); 33 | 34 | _eventNames.SetupIndex(); 35 | _methodNames.SetupIndex(); 36 | } 37 | 38 | protected override void UpdateSerializedProperties() 39 | { 40 | base.UpdateSerializedProperties(); 41 | 42 | _eventNames.UpdateProperty(); 43 | _methodNames.UpdateProperty(); 44 | } 45 | 46 | protected override void CollectSerializedProperties() 47 | { 48 | base.CollectSerializedProperties(); 49 | 50 | _eventNames.Init(serializedObject); 51 | _methodNames.Init(serializedObject); 52 | 53 | _srcViewProp = serializedObject.FindProperty("SrcView"); 54 | } 55 | 56 | protected override void CollectPropertyLists() 57 | { 58 | base.CollectPropertyLists(); 59 | 60 | _eventNames.Clear(); 61 | _methodNames.Clear(); 62 | 63 | var view = _srcViewProp.objectReferenceValue as Component; 64 | 65 | if (view) 66 | _eventNames.Values = view.GetBindableEventsList(); 67 | 68 | else 69 | _eventNames.Value = null; 70 | 71 | 72 | _methodNames.Values = ViewModelProvider.GetViewModelMethodNames(ViewModelName); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/EventBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a67c499c5a94bd4cb3e47a1d519d433 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/EventPropertyBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33b7b22578a6cb0499a5f04ac15cd9b6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/GUIStyles.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityMVVM.Editor 4 | { 5 | public class GUIStyles 6 | { 7 | 8 | static GUIStyle _bindingButton; 9 | 10 | public static GUIStyle BindingButton 11 | { 12 | get 13 | { 14 | if (_bindingButton == null) 15 | { 16 | _bindingButton = new GUIStyle(GUI.skin.button) 17 | { 18 | richText = true, 19 | margin = new RectOffset(0, 0, 0, 0), 20 | stretchHeight = false 21 | }; 22 | _bindingButton.active.background = _bindingButton.normal.background; 23 | } 24 | 25 | return _bindingButton; 26 | } 27 | } 28 | 29 | static GUIStyle _bindingLabel; 30 | public static GUIStyle LabelCenter 31 | { 32 | get 33 | { 34 | if (_bindingLabel == null) 35 | _bindingLabel = new GUIStyle(GUI.skin.label) 36 | { 37 | richText = true, 38 | alignment = TextAnchor.MiddleRight 39 | }; 40 | 41 | return _bindingLabel; 42 | } 43 | } 44 | 45 | public static GUIStyle _labelLeft; 46 | 47 | public static GUIStyle LabelLeft 48 | { 49 | get 50 | { 51 | if (_labelLeft == null) 52 | _labelLeft = new GUIStyle(LabelCenter) 53 | { 54 | alignment = TextAnchor.MiddleLeft 55 | }; 56 | return _labelLeft; 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/GUIStyles.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b084b3cf6d31414289ca6771f94ae51 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/GUIUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b6bcf2493c24e84b8f0a60edad6800f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/MVVMBaseEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityMVVM.Types; 3 | 4 | [CustomEditor(typeof(MVVMBase))] 5 | public abstract class MVVMBaseEditor : UnityEditor.Editor 6 | { 7 | protected virtual void OnEnable() 8 | { 9 | CollectSerializedProperties(); 10 | 11 | CollectPropertyLists(); 12 | 13 | serializedObject.ApplyModifiedProperties(); 14 | 15 | UpdateSerializedProperties(); 16 | } 17 | 18 | protected abstract void CollectSerializedProperties(); 19 | 20 | protected abstract void DrawChangeableElements(); 21 | 22 | protected abstract void UpdateSerializedProperties(); 23 | 24 | protected abstract void SetupDropdownIndices(); 25 | 26 | protected abstract void CollectPropertyLists(); 27 | 28 | public override void OnInspectorGUI() 29 | { 30 | serializedObject.Update(); 31 | 32 | SetupDropdownIndices(); 33 | 34 | EditorGUI.BeginChangeCheck(); 35 | 36 | DrawChangeableElements(); 37 | 38 | if (EditorGUI.EndChangeCheck()) 39 | { 40 | UpdateSerializedProperties(); 41 | 42 | EditorUtility.SetDirty(target); 43 | 44 | CollectPropertyLists(); 45 | 46 | serializedObject.ApplyModifiedProperties(); 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/MVVMBaseEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22676bcaf05948a4796c52ccd1ace21d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/OneWayDataBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | using UnityMVVM.Binding; 7 | using UnityMVVM.Binding.Converters; 8 | using UnityMVVM.Extensions; 9 | using UnityMVVM.Util; 10 | 11 | namespace UnityMVVM.Editor 12 | { 13 | [CanEditMultipleObjects] 14 | [CustomEditor(typeof(OneWayDataBinding), true)] 15 | public class OneWayDataBindingEditor 16 | : DataBindingBaseEditor 17 | { 18 | protected SerializedProperty _dstViewProp; 19 | protected SerializedProperty _converterProp; 20 | 21 | protected SerializedList _srcNames = new SerializedList("SrcPropertyName"); 22 | protected SerializedList _srcPaths = new SerializedList("SrcPropertyPath"); 23 | protected SerializedList _dstNames = new SerializedList("DstPropertyName"); 24 | protected SerializedList _dstPaths = new SerializedList("DstPropertyPath"); 25 | 26 | protected override void CollectSerializedProperties() 27 | { 28 | base.CollectSerializedProperties(); 29 | 30 | _srcNames.Init(serializedObject); 31 | _srcPaths.Init(serializedObject); 32 | _dstNames.Init(serializedObject); 33 | _dstPaths.Init(serializedObject); 34 | 35 | _dstViewProp = serializedObject.FindProperty("_dstView"); 36 | _converterProp = serializedObject.FindProperty("_converter"); 37 | } 38 | 39 | 40 | protected override void DrawChangeableElements() 41 | { 42 | if (string.IsNullOrEmpty(_viewModelProp.Value)) 43 | { 44 | base.DrawChangeableElements(); 45 | return; 46 | } 47 | if (target.GetType().GetCustomAttributes(typeof(ObsoleteAttribute), false).FirstOrDefault() != null) 48 | { 49 | 50 | GUIUtils.Message("Use button below to update component."); 51 | GUIUtils.Message("THIS WILL REPLACE THIS COMPONENT AND CANNOT BE UNDONE", MessageType.Error); 52 | if (GUILayout.Button("Update Component")) 53 | (target as DataBindingBase).UpdateComponent(); 54 | } 55 | 56 | GUIUtils.ObjectField("Dest View", _dstViewProp); 57 | 58 | base.DrawChangeableElements(); 59 | 60 | GUIUtils.BindingField("Source Property", _srcNames, _srcPaths); 61 | 62 | GUIUtils.ObjectField("Converter", _converterProp); 63 | 64 | GUIUtils.BindingField("Destination Property", _dstNames, _dstPaths); 65 | } 66 | 67 | protected override void SetupDropdownIndices() 68 | { 69 | base.SetupDropdownIndices(); 70 | 71 | _srcNames.SetupIndex(); 72 | _srcPaths.SetupIndex(); 73 | 74 | _dstNames.SetupIndex(); 75 | _dstPaths.SetupIndex(); 76 | } 77 | 78 | protected override void UpdateSerializedProperties() 79 | { 80 | base.UpdateSerializedProperties(); 81 | 82 | _srcNames.UpdateProperty(); 83 | _srcPaths.UpdateProperty(); 84 | 85 | _dstNames.UpdateProperty(); 86 | _dstPaths.UpdateProperty(); 87 | } 88 | 89 | protected override void CollectPropertyLists() 90 | { 91 | base.CollectPropertyLists(); 92 | 93 | if (_viewModelChanged) 94 | { 95 | _srcNames.Value = null; 96 | _srcPaths.Value = null; 97 | } 98 | 99 | if (string.IsNullOrEmpty(_viewModelProp.Value)) 100 | return; 101 | 102 | var view = _dstViewProp.objectReferenceValue as Component; 103 | 104 | _srcNames.Clear(); 105 | _srcPaths.Clear(); 106 | _dstNames.Clear(); 107 | _dstPaths.Clear(); 108 | 109 | 110 | if (view) 111 | { 112 | _dstNames.Values = view.GetBindablePropertyList(needsGetter: false); 113 | _dstPaths.Values = view.GetPropertiesAndFieldsList(_dstNames.Value); 114 | } 115 | else 116 | { 117 | _dstNames.Value = null; 118 | _dstPaths.Value = null; 119 | } 120 | 121 | var vmType = ViewModelProvider.GetViewModelType(ViewModelName); 122 | 123 | _srcNames.Values = ViewModelProvider.GetViewModelPropertyList(ViewModelName); 124 | 125 | var propType = vmType.GetProperty(_srcNames.Value)?.PropertyType; 126 | if (propType != null) 127 | _srcPaths.Values = propType.GetNestedFields(); 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/OneWayDataBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad855778833fe1942a36b0be898e9206 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/PackageUpdater.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityMVVM.Editor 7 | { 8 | public class PackageUpdater 9 | { 10 | [MenuItem("Unity-MVVM/Update Package")] 11 | public static void Update() 12 | { 13 | UnityEditor.PackageManager.Client.Add("https://github.com/push-pop/Unity-MVVM.git#upm"); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/PackageUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cdc7ee2892ee9d4e874942921d88f5d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/SerializedList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | 6 | namespace UnityMVVM.Editor 7 | { 8 | public class SerializedList 9 | { 10 | public List Values 11 | { 12 | get => values; 13 | set 14 | { 15 | values = value; 16 | if (string.IsNullOrEmpty(Value)) 17 | { 18 | Value = values.FirstOrDefault(); 19 | } 20 | } 21 | } 22 | 23 | List values = new List(); 24 | public string Value 25 | { 26 | get 27 | { 28 | return _backingProp.stringValue; 29 | } 30 | set 31 | { 32 | _backingProp.stringValue = value; 33 | } 34 | } 35 | 36 | public int Index { get => _idx; set => _idx = value; } 37 | SerializedProperty _backingProp; 38 | string propertyName; 39 | int _idx = -1; 40 | 41 | public SerializedList(string propName) 42 | { 43 | propertyName = propName; 44 | } 45 | 46 | public void Init(SerializedObject serializedObject) 47 | { 48 | _backingProp = serializedObject.FindProperty(propertyName); 49 | } 50 | 51 | public void SetupIndex() 52 | { 53 | _idx = values.IndexOf(_backingProp.stringValue); 54 | 55 | if (_idx < 0 && values.Count > 0) 56 | { 57 | _idx = 0; 58 | if (_backingProp != null && values != null) 59 | _backingProp.stringValue = values.FirstOrDefault(); 60 | } 61 | } 62 | 63 | public void UpdateProperty() 64 | { 65 | _backingProp.stringValue = _idx > -1 ? values[_idx] : null; 66 | } 67 | 68 | public void Clear() 69 | { 70 | values.Clear(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/SerializedList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c78a2905778f7a4ca116ce6f7eeab13 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/TwoWayDataBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityMVVM.Binding; 6 | using UnityMVVM.Extensions; 7 | 8 | namespace UnityMVVM.Editor 9 | { 10 | [CustomEditor(typeof(TwoWayDataBinding), true)] 11 | public class TwoWayDataBindingEditor : OneWayDataBindingEditor 12 | { 13 | int _eventIdx = -1; 14 | 15 | SerializedList _eventNames = new SerializedList("_dstChangedEventName"); 16 | 17 | protected override void SetupDropdownIndices() 18 | { 19 | base.SetupDropdownIndices(); 20 | 21 | _eventNames.SetupIndex(); 22 | } 23 | 24 | protected override void CollectSerializedProperties() 25 | { 26 | base.CollectSerializedProperties(); 27 | 28 | _eventNames.Init(serializedObject); 29 | } 30 | 31 | protected override void DrawChangeableElements() 32 | { 33 | base.DrawChangeableElements(); 34 | 35 | GUIUtils.BindingField("Dest Changed Event", _eventNames); 36 | } 37 | 38 | protected override void UpdateSerializedProperties() 39 | { 40 | base.UpdateSerializedProperties(); 41 | 42 | _eventNames.UpdateProperty(); 43 | } 44 | 45 | protected override void CollectPropertyLists() 46 | { 47 | base.CollectPropertyLists(); 48 | 49 | var view = _dstViewProp.objectReferenceValue as UnityEngine.Component; 50 | 51 | _eventNames.Clear(); 52 | 53 | if (view) 54 | _eventNames.Values = view.GetBindableEventsList(); 55 | else 56 | _eventNames.Value = null; 57 | 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/TwoWayDataBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ed3e1cab98c7104795980b03ebd7ed0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/Unity-MVVM.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Unity-MVVM-Editor", 3 | "references": [ 4 | "GUID:889b57d9d5be29f419d21d9c7a4b24fa" 5 | ], 6 | "includePlatforms": [ 7 | "Editor" 8 | ], 9 | "excludePlatforms": [], 10 | "allowUnsafeCode": false, 11 | "overrideReferences": true, 12 | "precompiledReferences": [], 13 | "autoReferenced": true, 14 | "defineConstraints": [], 15 | "versionDefines": [], 16 | "noEngineReferences": false 17 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/Unity-MVVM.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af68265d5e48dab4da1f4a2be9d10068 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/UpdateComponentsEditorWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityMVVM.Binding; 6 | using UnityMVVM.Editor; 7 | 8 | public class UpdateComponentsEditorWindow : EditorWindow 9 | { 10 | Vector2 scrollPos = Vector2.zero; 11 | 12 | [MenuItem("Unity-MVVM/Component Updater")] 13 | static void Init() 14 | { 15 | var window = (UpdateComponentsEditorWindow)GetWindow(); 16 | window.titleContent = new UnityEngine.GUIContent("Update Components"); 17 | window.Show(); 18 | } 19 | 20 | private void OnGUI() 21 | { 22 | GUIUtils.Message("Use this utility to replace all deprecated components with their new counterparts."); 23 | GUIUtils.Message("WARNING: THIS IS A DESTRUCTIVE OPERATION. PLEASE MAKE SURE YOU HAVE A BACKUP BEFORE ATTEMPTING!!!", MessageType.Error); 24 | 25 | EditorGUILayout.Space(); 26 | GUIUtils.Message("The following components will be updated:"); 27 | 28 | var obsoleteComponents = FindObjectsOfType() 29 | .Where(e=>e.GetType().GetCustomAttributes(typeof(ObsoleteAttribute), true).FirstOrDefault() != null); 30 | 31 | scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.MaxHeight(600)); 32 | 33 | 34 | foreach (var item in obsoleteComponents) 35 | { 36 | GUIUtils.Message($"{item.gameObject} - {item.GetType().Name} -> DataBinding"); 37 | } 38 | 39 | EditorGUILayout.EndScrollView(); 40 | 41 | if (GUILayout.Button("Update Components")) 42 | { 43 | foreach (var item in obsoleteComponents) 44 | { 45 | var isObsolete = item.GetType().GetCustomAttributes(typeof(ObsoleteAttribute),false).FirstOrDefault(); 46 | 47 | if (!item.UpdateComponent()) 48 | Debug.LogError($"Failed to update component {item} on {item.gameObject}"); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Editor/UpdateComponentsEditorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07a4c5a3c88927f44bb2d18b2c9a76b3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Nate Turley 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fbd6efb37a86f64cb7c4edd714bec40 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d8c7a48c41c6cf49a8ca0fc3ae27d5a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6faa3937cc3c5148938989a3fc06bb6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/AssemblyTest.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93c482ca76b0e8d4fa061cd0562873cd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/AssemblyTest/AssemblyTestScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d07154db4517094d803f54091adbd09 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/AssemblyTest/AssemblyViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System.Reflection; 5 | using UnityMVVM.ViewModel; 6 | 7 | namespace UnityMVVM.Samples 8 | { 9 | public class AssemblyViewModel : ViewModelBase 10 | { 11 | public string AssemblyName => Assembly.GetExecutingAssembly().FullName; 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/AssemblyTest/AssemblyViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18921eabc5fcead4397482282ab42e22 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/AssemblyTest/TestAssembly.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TestAssembly", 3 | "references": [ 4 | "GUID:af68265d5e48dab4da1f4a2be9d10068", 5 | "GUID:889b57d9d5be29f419d21d9c7a4b24fa" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": true, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/AssemblyTest/TestAssembly.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 433cd59b1281a404db486dc70603fff7 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 735af9786a2af3144a59e2a095f2f62a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/CanvasView.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ece151609ffb5340b20c5cc5491d0fe 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/DataBinding.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89b0ee7f494585f4b8d0e79e16373cd0 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/DataBindings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f3e5b30e2016404fb2ccd5c8c6eb7c0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/DataBindings/Converters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a93a0eb734329324f8a9a68a01e452d9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/DataBindings/Converters/BoolToColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityMVVM.Binding.Converters; 6 | 7 | namespace UnityMVVM.Samples.BasicUsage 8 | { 9 | public class BoolToColorConverter : ValueConverterBase 10 | { 11 | [SerializeField] 12 | Color _trueColor = Color.green; 13 | 14 | [SerializeField] 15 | Color _falseColor = Color.red; 16 | 17 | public override object Convert(object value, Type targetType, object parameter) 18 | { 19 | return (bool)value ? _trueColor : _falseColor; 20 | } 21 | 22 | public override object ConvertBack(object value, Type targetType, object parameter) 23 | { 24 | Debug.LogError($"{GetType().Name} ConvertBack not implemented. Override this class if you wish to implement"); 25 | return null; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/DataBindings/Converters/BoolToColorConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae1e44f6b44227e45ba7e781cd80106b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/DataBindings/ViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 150008764de9aeb46a2519bbebdb3fc9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/Events.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19c8ae53ebbec6447b149872ec9d6ae3 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/Views.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ffd152e3cc56f44a8648d067b0f59e4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/Views/UsingViewsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class UsingViewsViewModel : MonoBehaviour 6 | { 7 | // Start is called before the first frame update 8 | void Start() 9 | { 10 | 11 | } 12 | 13 | // Update is called once per frame 14 | void Update() 15 | { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/Views/UsingViewsViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc64eaf4e0d902b40a235eaa4633877c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/Views/ViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityMVVM.ViewModel; 5 | 6 | namespace UnityMVVM.Samples.UsingViews 7 | { 8 | public class ViewModel : ViewModelBase 9 | { 10 | public bool IsViewOpen 11 | { 12 | get { return _isViewOpen; } 13 | set 14 | { 15 | if (value != _isViewOpen) 16 | { 17 | _isViewOpen = value; 18 | NotifyPropertyChanged(nameof(IsViewOpen)); 19 | } 20 | } 21 | } 22 | 23 | [SerializeField] 24 | private bool _isViewOpen; 25 | 26 | public void ToggleViewVisibility() 27 | { 28 | IsViewOpen = !IsViewOpen; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/Basic Usage/Views/ViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a98fec434e823240aa03e32a0df66e1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8e02eca131f1684e83637adb975a6c8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/MVVMTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f6f8d2a92129494a8508d79906ee929 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a5e113237b01c14698607f44af54ae4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Prefabs/TextPrefab.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06dac52260a02814dbfacec458252957 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 414d7fda99e365e428795174f972727a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0965b6e92ff1842488f26ac305e4a6df 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters/ColorToTextConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityMVVM.Binding.Converters; 4 | 5 | namespace UnityMVVM.Samples.MVVMTest 6 | { 7 | public class ColorToTextConverter : ValueConverterBase 8 | { 9 | public override object Convert(object value, Type targetType, object parameter) 10 | { 11 | return string.Format("The Color is: {0}", ((Color)value)); 12 | } 13 | 14 | public override object ConvertBack(object value, Type targetType, object parameter) 15 | { 16 | Debug.LogError($"{GetType().Name} ConvertBack not implemented. Override this class if you wish to implement"); 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters/ColorToTextConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b9972c40b2423a4085917c7ddabf4b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters/IntToColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityMVVM.Binding.Converters; 6 | 7 | namespace UnityMVVM.Samples.MVVMTest 8 | { 9 | public class IntToColorConverter : ValueConverterBase 10 | { 11 | 12 | public override object Convert(object value, Type targetType, object parameter) 13 | { 14 | var num = (int)value; 15 | 16 | switch (num % 5) 17 | { 18 | case 0: 19 | return Color.black; 20 | case 1: 21 | return Color.blue; 22 | case 3: 23 | return Color.red; 24 | case 4: 25 | return Color.yellow; 26 | default: 27 | return Color.white; 28 | } 29 | 30 | 31 | } 32 | 33 | public override object ConvertBack(object value, Type targetType, object parameter) 34 | { 35 | Debug.LogError($"{GetType().Name} ConvertBack not implemented. Override this class if you wish to implement"); 36 | return null; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters/IntToColorConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20c2920710bec3e41936d64d12563642 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters/StateToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityMVVM.Binding.Converters; 4 | using UnityMVVM.View; 5 | 6 | namespace UnityMVVM.Samples.MVVMTest 7 | { 8 | public class StateToVisibilityConverter : ValueConverterBase 9 | { 10 | public ApplicationState VisibleState; 11 | public ApplicationState HiddenState; 12 | public ApplicationState CollapsedState; 13 | 14 | public override object Convert(object value, Type targetType, object parameter) 15 | { 16 | ApplicationState state = (ApplicationState)value; 17 | if (state == VisibleState) 18 | return Visibility.Visible; 19 | if (state == HiddenState) 20 | return Visibility.Hidden; 21 | if (state == CollapsedState) 22 | return Visibility.Collapsed; 23 | 24 | return null; 25 | } 26 | 27 | public override object ConvertBack(object value, Type targetType, object parameter) 28 | { 29 | Debug.LogError($"{GetType().Name} ConvertBack not implemented. Override this class if you wish to implement"); 30 | return null; 31 | } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/Converters/StateToVisibilityConverter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b66c4dceeb81c84b81543801f1ce902 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/TestViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9049d834eb3dd594183991ea6c3554df 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/TextItem.cs: -------------------------------------------------------------------------------- 1 | using UnityMVVM.View; 2 | 3 | namespace UnityMVVM.Samples.MVVMTest 4 | { 5 | public class TextItem : CollectionViewItemBase 6 | { 7 | public override void InitItem(TextItemModel model, int idx) 8 | { 9 | } 10 | 11 | public override void UpdateItem(TextItemModel model, int newIdx) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/TextItem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e779f647aee11154fbb27dff89319f97 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/TwoWayBoolTest.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using UnityEngine.UI; 4 | using UnityMVVM.View; 5 | 6 | namespace UnityMVVM.Samples.MVVMTest 7 | { 8 | public class UnityBoolEvent : UnityEvent { } 9 | 10 | public class TwoWayBoolTest : ViewBase 11 | { 12 | [SerializeField] 13 | Image _indicator; 14 | 15 | [SerializeField] 16 | Button _btn; 17 | 18 | 19 | public bool BoolProp 20 | { 21 | get => _boolProp; 22 | set 23 | { 24 | if (_boolProp != value) 25 | { 26 | _boolProp = value; 27 | _indicator.color = _boolProp ? Color.blue : Color.red; 28 | 29 | OnBoolChanged?.Invoke(value); 30 | } 31 | } 32 | } 33 | 34 | bool _boolProp; 35 | 36 | public UnityBoolEvent OnBoolChanged { get; set; } = new UnityBoolEvent(); 37 | 38 | private void Awake() 39 | { 40 | 41 | _btn.onClick.AddListener(new UnityEngine.Events.UnityAction(() => 42 | { 43 | BoolProp = !BoolProp; 44 | })); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/Scripts/TwoWayBoolTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3619aaaf66aa7d14f9a216a0d6bd0ae3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/TextItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityMVVM.Model; 4 | 5 | namespace UnityMVVM.Samples.MVVMTest 6 | { 7 | [Serializable] 8 | public class TextItemModel : ModelBase 9 | { 10 | public string message { get => _message; set => _message = value; } 11 | public Color color { get => _color; set => _color = value; } 12 | 13 | [SerializeField] 14 | Color _color; 15 | 16 | [SerializeField] 17 | string _message; 18 | 19 | 20 | public override string ToString() 21 | { 22 | return string.Format("Message: {0} Color: {1}", message, color); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/MVVMTest/TextItemModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b853f9dc03b0a8b41a986336643fd871 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/PropertyPaths.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b77f53bdabd639c47bc96a94572a8bb4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/PropertyPaths/PropertyPaths.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4645ec4668b94e84c8bc14ac267925a2 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/PropertyPaths/PropertyPathsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityMVVM.ViewModel; 4 | 5 | namespace UnityMVVM.Samples.PropertyPaths 6 | { 7 | public class PropertyPathsViewModel : ViewModelBase 8 | { 9 | [System.Serializable] 10 | public class NestedPropSrc : IEquatable 11 | { 12 | public float floatField; 13 | public int intField; 14 | 15 | public bool Equals(NestedPropSrc other) 16 | { 17 | other = other as NestedPropSrc; 18 | 19 | return floatField == other.floatField && intField == other.intField; 20 | } 21 | } 22 | 23 | public NestedPropSrc NestedProp 24 | { 25 | get { return _nestedProp; } 26 | set 27 | { 28 | if (value != _nestedProp) 29 | { 30 | _nestedProp = value; 31 | NotifyPropertyChanged(nameof(NestedProp)); 32 | } 33 | } 34 | } 35 | 36 | [SerializeField] 37 | private NestedPropSrc _nestedProp = new NestedPropSrc(); 38 | 39 | private void Update() 40 | { 41 | NestedProp.floatField = Mathf.Sin(Time.time * 2); 42 | NotifyPropertyChanged(nameof(NestedProp)); 43 | } 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/PropertyPaths/PropertyPathsViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 053a2c1fa3dc50a4d9495f51d25614af 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/SelectableCollectionView.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 686a8036cb75d2b41bc740e309101e5f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/SelectableCollectionView/ButtoModel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityMVVM.Model; 3 | 4 | namespace UnityMVVM.Samples.SelectableCollectionView 5 | { 6 | public class ButtonModel : ModelBase 7 | { 8 | public Color color { get; set; } 9 | public string label { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/SelectableCollectionView/ButtoModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37244d30e9c15f14987393d8db0c2948 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Unity-MVVM/Samples/SelectableCollectionView/ButtonItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.UI; 6 | using UnityMVVM.Model; 7 | using UnityMVVM.View; 8 | 9 | namespace UnityMVVM.Samples.SelectableCollectionView 10 | { 11 | public class ButtonItem : CollectionViewItemBase, 12 | ISelectable 13 | { 14 | public bool IsSelected 15 | { 16 | get => _isSelected; 17 | set 18 | { 19 | if (_isSelected != value) 20 | { 21 | _isSelected = value; 22 | SetSelected(value); 23 | } 24 | } 25 | } 26 | 27 | bool _isSelected = false; 28 | 29 | public List _selectedItems; 30 | public List _unselectedItems; 31 | 32 | public UnityEvent OnClick { get; set; } = new UnityEvent(); 33 | public Action OnSelected { get; set; } 34 | public Action OnDeselected { get; set; } 35 | 36 | private void Awake() 37 | { 38 | GetComponent