├── .gitignore ├── Assets ├── 1_One_way_property_binding_to_a_text_field.meta ├── 1_One_way_property_binding_to_a_text_field │ ├── MyViewModel1.cs │ ├── MyViewModel1.cs.meta │ ├── One_way_property_binding_to_a_text_field.unity │ └── One_way_property_binding_to_a_text_field.unity.meta ├── 2_Two_way_property_binding_to_an_input_field.meta ├── 2_Two_way_property_binding_to_an_input_field │ ├── MyViewModel2.cs │ ├── MyViewModel2.cs.meta │ ├── Two_way_property_binding_to_an_input_field.unity │ └── Two_way_property_binding_to_an_input_field.unity.meta ├── 3_Binding_a_button_click.meta ├── 3_Binding_a_button_click │ ├── Binding_a_button_click.unity │ ├── Binding_a_button_click.unity.meta │ ├── MyViewModel3.cs │ └── MyViewModel3.cs.meta ├── 4_Combined_example.meta ├── 4_Combined_example │ ├── Combined_example.unity │ ├── Combined_example.unity.meta │ ├── MyViewModel4.cs │ └── MyViewModel4.cs.meta ├── 5_Validation.meta ├── 5_Validation │ ├── Color Validation Adapter Options.asset │ ├── Color Validation Adapter Options.asset.meta │ ├── ColorValidationAdapter.cs │ ├── ColorValidationAdapter.cs.meta │ ├── ColorValidationAdapterOptions.cs │ ├── ColorValidationAdapterOptions.cs.meta │ ├── ExceptionValidationAdapter.cs │ ├── ExceptionValidationAdapter.cs.meta │ ├── Float To String Adapter Options.asset │ ├── Float To String Adapter Options.asset.meta │ ├── ValidationViewModel.cs │ ├── ValidationViewModel.cs.meta │ ├── validation.unity │ └── validation.unity.meta ├── 6_Sliders.meta ├── 6_Sliders │ ├── MyViewModel6.cs │ ├── MyViewModel6.cs.meta │ ├── Sliders.unity │ └── Sliders.unity.meta ├── 7_Dropdown.meta ├── 7_Dropdown │ ├── Dropdown.unity │ ├── Dropdown.unity.meta │ ├── MyViewModel7.cs │ └── MyViewModel7.cs.meta ├── Collection.meta ├── Collection │ ├── Collection.unity │ ├── Collection.unity.meta │ ├── ItemViewModel.cs │ ├── ItemViewModel.cs.meta │ ├── MyUI3.cs │ └── MyUI3.cs.meta ├── SubViewModelBinding.meta ├── SubViewModelBinding │ ├── ColorViewModel.cs │ ├── ColorViewModel.cs.meta │ ├── ObjectViewModel.cs │ ├── ObjectViewModel.cs.meta │ ├── SubViewModelBinding.unity │ └── SubViewModelBinding.unity.meta ├── Template_selector.meta ├── Template_selector │ ├── AddressTab.cs │ ├── AddressTab.cs.meta │ ├── MyUI5.cs │ ├── MyUI5.cs.meta │ ├── NameTab.cs │ ├── NameTab.cs.meta │ ├── Tab.cs │ ├── Tab.cs.meta │ ├── Template_selector.unity │ └── Template_selector.unity.meta ├── Unity-Weld.meta └── Unity-Weld │ ├── Editor.meta │ ├── Editor │ ├── BaseBindingEditor.cs │ ├── BaseBindingEditor.cs.meta │ ├── CollectionBindingEditor.cs │ ├── CollectionBindingEditor.cs.meta │ ├── EventBindingEditor.cs │ ├── EventBindingEditor.cs.meta │ ├── InspectorUtils.cs │ ├── InspectorUtils.cs.meta │ ├── OneWayPropertyBindingEditor.cs │ ├── OneWayPropertyBindingEditor.cs.meta │ ├── SubViewModelBindingEditor.cs │ ├── SubViewModelBindingEditor.cs.meta │ ├── TemplateBindingEditor.cs │ ├── TemplateBindingEditor.cs.meta │ ├── TemplateEditor.cs │ ├── TemplateEditor.cs.meta │ ├── ToggleActiveBindingEditor.cs │ ├── ToggleActiveBindingEditor.cs.meta │ ├── TwoWayPropertyBindingEditor.cs │ └── TwoWayPropertyBindingEditor.cs.meta │ ├── UnityWeld.meta │ └── UnityWeld │ ├── AOTOptimisationHelper.cs │ ├── AOTOptimisationHelper.cs.meta │ ├── Binding.meta │ ├── Binding │ ├── AbstractMemberBinding.cs │ ├── AbstractMemberBinding.cs.meta │ ├── AbstractTemplateSelector.cs │ ├── AbstractTemplateSelector.cs.meta │ ├── AdapterAttribute.cs │ ├── AdapterAttribute.cs.meta │ ├── AdapterOptions.cs │ ├── AdapterOptions.cs.meta │ ├── Adapters.meta │ ├── Adapters │ │ ├── BoolInversionAdapter.cs │ │ ├── BoolInversionAdapter.cs.meta │ │ ├── BoolToColorAdapter.cs │ │ ├── BoolToColorAdapter.cs.meta │ │ ├── BoolToColorAdapterOptions.cs │ │ ├── BoolToColorAdapterOptions.cs.meta │ │ ├── BoolToColorBlockAdapter.cs │ │ ├── BoolToColorBlockAdapter.cs.meta │ │ ├── BoolToColorBlockAdapterOptions.cs │ │ ├── BoolToColorBlockAdapterOptions.cs.meta │ │ ├── BoolToStringAdapter.cs │ │ ├── BoolToStringAdapter.cs.meta │ │ ├── BoolToStringAdapterOptions.cs │ │ ├── BoolToStringAdapterOptions.cs.meta │ │ ├── DateTimeToStringAdapter.cs │ │ ├── DateTimeToStringAdapter.cs.meta │ │ ├── DateTimeToStringAdapterOptions.cs │ │ ├── DateTimeToStringAdapterOptions.cs.meta │ │ ├── FloatToStringAdapter.cs │ │ ├── FloatToStringAdapter.cs.meta │ │ ├── FloatToStringAdapterOptions.cs │ │ ├── FloatToStringAdapterOptions.cs.meta │ │ ├── IntToStringAdapter.cs │ │ ├── IntToStringAdapter.cs.meta │ │ ├── StringToFloatAdapter.cs │ │ ├── StringToFloatAdapter.cs.meta │ │ ├── StringToIntAdapter.cs │ │ └── StringToIntAdapter.cs.meta │ ├── BindingAttribute.cs │ ├── BindingAttribute.cs.meta │ ├── BoundObservableList.cs │ ├── BoundObservableList.cs.meta │ ├── CollectionBinding.cs │ ├── CollectionBinding.cs.meta │ ├── DropdownBinding.cs │ ├── DropdownBinding.cs.meta │ ├── EventBinding.cs │ ├── EventBinding.cs.meta │ ├── Exceptions.meta │ ├── Exceptions │ │ ├── AmbiguousTypeException.cs │ │ ├── AmbiguousTypeException.cs.meta │ │ ├── ComponentNotFoundException.cs │ │ ├── ComponentNotFoundException.cs.meta │ │ ├── InvalidAdapterException.cs │ │ ├── InvalidAdapterException.cs.meta │ │ ├── InvalidEndPointException.cs │ │ ├── InvalidEndPointException.cs.meta │ │ ├── InvalidEventException.cs │ │ ├── InvalidEventException.cs.meta │ │ ├── InvalidTypeException.cs │ │ ├── InvalidTypeException.cs.meta │ │ ├── MemberNotFoundException.cs │ │ ├── MemberNotFoundException.cs.meta │ │ ├── NoSuchAdapterException.cs │ │ ├── NoSuchAdapterException.cs.meta │ │ ├── PropertyNullException.cs │ │ ├── PropertyNullException.cs.meta │ │ ├── TemplateNotFoundException.cs │ │ ├── TemplateNotFoundException.cs.meta │ │ ├── ViewModelNotFoundException.cs │ │ └── ViewModelNotFoundException.cs.meta │ ├── IAdapter.cs │ ├── IAdapter.cs.meta │ ├── IMemberBinding.cs │ ├── IMemberBinding.cs.meta │ ├── INotifyCollectionChanged.cs │ ├── INotifyCollectionChanged.cs.meta │ ├── ITypedList.cs │ ├── ITypedList.cs.meta │ ├── IViewModelProvider.cs │ ├── IViewModelProvider.cs.meta │ ├── Internal.meta │ ├── Internal │ │ ├── BindableMember.cs │ │ ├── BindableMember.cs.meta │ │ ├── PropertyEndPoint.cs │ │ ├── PropertyEndPoint.cs.meta │ │ ├── PropertyFinder.cs │ │ ├── PropertyFinder.cs.meta │ │ ├── PropertySync.cs │ │ ├── PropertySync.cs.meta │ │ ├── PropertyWatcher.cs │ │ ├── PropertyWatcher.cs.meta │ │ ├── TypeResolver.cs │ │ ├── TypeResolver.cs.meta │ │ ├── UnityEventBinder.cs │ │ ├── UnityEventBinder.cs.meta │ │ ├── UnityEventWatcher.cs │ │ └── UnityEventWatcher.cs.meta │ ├── NotifyCollectionChangedEventArgs.cs │ ├── NotifyCollectionChangedEventArgs.cs.meta │ ├── ObservableList.cs │ ├── ObservableList.cs.meta │ ├── OneWayPropertyBinding.cs │ ├── OneWayPropertyBinding.cs.meta │ ├── SubViewModelBinding.cs │ ├── SubViewModelBinding.cs.meta │ ├── Template.cs │ ├── Template.cs.meta │ ├── TemplateBinding.cs │ ├── TemplateBinding.cs.meta │ ├── ToggleActiveBinding.cs │ ├── ToggleActiveBinding.cs.meta │ ├── TwoWayPropertyBinding.cs │ └── TwoWayPropertyBinding.cs.meta │ ├── Widgets.meta │ └── Widgets │ ├── DropdownAdapter.cs │ └── DropdownAdapter.cs.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset ├── README.md └── UnityPackageManager └── manifest.json /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | .vs 21 | *.ncrunchproject 22 | *.ncrunchsolution 23 | 24 | 25 | # Unity3D generated meta files 26 | *.pidb.meta 27 | 28 | # Unity3D Generated File On Crash Reports 29 | sysinfo.txt 30 | 31 | # Builds 32 | *.apk 33 | *.unitypackage 34 | *.bak 35 | *.bak.meta 36 | 37 | # Swapfiles 38 | *.swp 39 | 40 | -------------------------------------------------------------------------------- /Assets/1_One_way_property_binding_to_a_text_field.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf4342456b60c3c4c83f86309df2a677 3 | folderAsset: yes 4 | timeCreated: 1474419632 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/1_One_way_property_binding_to_a_text_field/MyViewModel1.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using UnityWeld.Binding; 4 | 5 | [Binding] 6 | public class MyViewModel1 : MonoBehaviour, INotifyPropertyChanged 7 | { 8 | private float timer = 0; 9 | 10 | private string text = ""; 11 | 12 | [Binding] 13 | public string Text 14 | { 15 | get 16 | { 17 | return text; 18 | } 19 | set 20 | { 21 | if (text == value) 22 | { 23 | return; // No change. 24 | } 25 | 26 | text = value; 27 | 28 | OnPropertyChanged("Text"); 29 | } 30 | } 31 | 32 | /// 33 | /// Event to raise when a property's value has changed. 34 | /// 35 | public event PropertyChangedEventHandler PropertyChanged; 36 | 37 | // Use this for initialization 38 | void Start() 39 | { 40 | SetRandomText(); 41 | } 42 | 43 | // Update is called once per frame 44 | void Update() 45 | { 46 | timer += Time.deltaTime; 47 | 48 | if (timer >= 1f) 49 | { 50 | SetRandomText(); 51 | timer = 0f; 52 | } 53 | } 54 | 55 | private void OnPropertyChanged(string propertyName) 56 | { 57 | if (PropertyChanged != null) 58 | { 59 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 60 | } 61 | } 62 | 63 | public void SetRandomText() 64 | { 65 | Text = Random.Range(0f, 10000f).ToString(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Assets/1_One_way_property_binding_to_a_text_field/MyViewModel1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5dc40af6984ad674398ee644bf27257f 3 | timeCreated: 1474419649 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/1_One_way_property_binding_to_a_text_field/One_way_property_binding_to_a_text_field.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b0893081a347d41a61db299e0ab613 3 | timeCreated: 1474419632 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/2_Two_way_property_binding_to_an_input_field.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8ceeaaa93e228b4e90dbbb3c361331b 3 | folderAsset: yes 4 | timeCreated: 1476230358 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/2_Two_way_property_binding_to_an_input_field/MyViewModel2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using UnityWeld.Binding; 4 | 5 | namespace TwoWayExample 6 | { 7 | [Binding] 8 | public class MyViewModel2 : MonoBehaviour, INotifyPropertyChanged 9 | { 10 | private string text = ""; 11 | 12 | [Binding] 13 | public string Text 14 | { 15 | get 16 | { 17 | return text; 18 | } 19 | set 20 | { 21 | if (text == value) 22 | { 23 | return; // No change. 24 | } 25 | 26 | text = value; 27 | 28 | OnPropertyChanged("Text"); 29 | } 30 | } 31 | 32 | /// 33 | /// Event to raise when a property's value has changed. 34 | /// 35 | public event PropertyChangedEventHandler PropertyChanged; 36 | 37 | // Use this for initialization 38 | void Start() 39 | { 40 | } 41 | 42 | // Update is called once per frame 43 | void Update() 44 | { 45 | } 46 | 47 | private void OnPropertyChanged(string propertyName) 48 | { 49 | if (PropertyChanged != null) 50 | { 51 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/2_Two_way_property_binding_to_an_input_field/MyViewModel2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a870d5abd9f9bce4089cd3c7af117793 3 | timeCreated: 1476230430 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/2_Two_way_property_binding_to_an_input_field/Two_way_property_binding_to_an_input_field.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9bf0698ad7c87a4b806d71062dc8881 3 | timeCreated: 1476230358 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/3_Binding_a_button_click.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9325d6a8d626bc441842ae06caca854d 3 | folderAsset: yes 4 | timeCreated: 1477267556 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/3_Binding_a_button_click/Binding_a_button_click.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d97ab902d98761f4aa0c862bda33126e 3 | timeCreated: 1477267556 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/3_Binding_a_button_click/MyViewModel3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityWeld.Binding; 3 | 4 | namespace ButtonClickExample 5 | { 6 | [Binding] 7 | public class MyViewModel3 : MonoBehaviour 8 | { 9 | private float cubeRotation = 0f; 10 | 11 | [Binding] 12 | public void RotateCube() 13 | { 14 | cubeRotation = cubeRotation + 10f; 15 | } 16 | 17 | void Update() 18 | { 19 | var cube = GameObject.Find("Cube"); 20 | cube.transform.localEulerAngles = new Vector3(0f, cubeRotation, 0f); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Assets/3_Binding_a_button_click/MyViewModel3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dbe74fec2ddf554a9e86ed883ab4605 3 | timeCreated: 1477267619 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/4_Combined_example.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0dda991d4dd41944c826efc602833a8c 3 | folderAsset: yes 4 | timeCreated: 1477353617 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/4_Combined_example/Combined_example.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d774be0dea376a84083611083f738372 3 | timeCreated: 1477353617 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/4_Combined_example/MyViewModel4.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.ComponentModel; 4 | using UnityWeld.Binding; 5 | 6 | [Binding] 7 | public class MyViewModel4 : MonoBehaviour, INotifyPropertyChanged 8 | { 9 | private float cubeRotation = 0f; 10 | 11 | private string text = "0"; 12 | 13 | [Binding] 14 | public string Text 15 | { 16 | get 17 | { 18 | return text; 19 | } 20 | set 21 | { 22 | if (text == value) 23 | { 24 | return; // No change. 25 | } 26 | 27 | text = value; 28 | 29 | try 30 | { 31 | cubeRotation = float.Parse(text); 32 | } 33 | catch (Exception ex) 34 | { 35 | Debug.LogException(ex); 36 | } 37 | 38 | OnPropertyChanged("Text"); 39 | } 40 | } 41 | 42 | /// 43 | /// Event to raise when a property's value has changed. 44 | /// 45 | public event PropertyChangedEventHandler PropertyChanged; 46 | 47 | [Binding] 48 | public void RotateCube() 49 | { 50 | cubeRotation = cubeRotation + 10f; 51 | text = cubeRotation.ToString(); 52 | 53 | OnPropertyChanged("Text"); 54 | } 55 | 56 | void Update() 57 | { 58 | var cube = GameObject.Find("Cube"); 59 | cube.transform.localEulerAngles = new Vector3(0f, cubeRotation, 0f); 60 | } 61 | 62 | private void OnPropertyChanged(string propertyName) 63 | { 64 | if (PropertyChanged != null) 65 | { 66 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/4_Combined_example/MyViewModel4.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97cfc70c4963f09478cf48082b32454e 3 | timeCreated: 1477353633 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/5_Validation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd678cabf9690044f9151bf5187392eb 3 | folderAsset: yes 4 | timeCreated: 1479086240 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/5_Validation/Color Validation Adapter Options.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: 432f62b62ce9a2847ac67c0bc0a063bd, type: 3} 12 | m_Name: Color Validation Adapter Options 13 | m_EditorClassIdentifier: 14 | NormalColor: 15 | m_NormalColor: {r: 1, g: 1, b: 1, a: 1} 16 | m_HighlightedColor: {r: 1, g: 1, b: 1, a: 1} 17 | m_PressedColor: {r: 1, g: 1, b: 1, a: 1} 18 | m_DisabledColor: {r: 1, g: 1, b: 1, a: 1} 19 | m_ColorMultiplier: 1 20 | m_FadeDuration: 0.1 21 | InvalidColor: 22 | m_NormalColor: {r: 1, g: 0, b: 0, a: 1} 23 | m_HighlightedColor: {r: 1, g: 0, b: 0, a: 1} 24 | m_PressedColor: {r: 1, g: 0, b: 0, a: 1} 25 | m_DisabledColor: {r: 1, g: 0, b: 0, a: 1} 26 | m_ColorMultiplier: 1 27 | m_FadeDuration: 0.1 28 | -------------------------------------------------------------------------------- /Assets/5_Validation/Color Validation Adapter Options.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9dff743a1413daf4b93861eba4924f0e 3 | timeCreated: 1488850864 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/5_Validation/ColorValidationAdapter.cs: -------------------------------------------------------------------------------- 1 | using Assets._5_Validation; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | using UnityWeld.Binding; 5 | 6 | namespace ValidationExample 7 | { 8 | [Adapter(typeof(bool), typeof(ColorBlock), typeof(ColorValidationAdapterOptions))] 9 | public class ColorValidationAdapter : IAdapter 10 | { 11 | public object Convert(object valueIn, AdapterOptions adapterOptions) 12 | { 13 | var isValid = (bool)valueIn; 14 | var options = (ColorValidationAdapterOptions) adapterOptions; 15 | 16 | return isValid ? options.NormalColor : options.InvalidColor; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Assets/5_Validation/ColorValidationAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 520ed33cf59e8854e94879a57266afee 3 | timeCreated: 1477283231 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/5_Validation/ColorValidationAdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | using UnityWeld.Binding; 8 | 9 | namespace Assets._5_Validation 10 | { 11 | [CreateAssetMenu(menuName = "Unity Weld/Adapter options/Color validation adapter")] 12 | public class ColorValidationAdapterOptions : AdapterOptions 13 | { 14 | [Header("Valid color")] 15 | public ColorBlock NormalColor; 16 | 17 | [Space] 18 | 19 | [Header("Invalid color")] 20 | public ColorBlock InvalidColor; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/5_Validation/ColorValidationAdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 432f62b62ce9a2847ac67c0bc0a063bd 3 | timeCreated: 1488773890 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/5_Validation/ExceptionValidationAdapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityWeld.Binding; 3 | 4 | [Adapter(typeof(Exception), typeof(bool))] 5 | public class ExceptionValidationAdapter : IAdapter 6 | { 7 | public object Convert(object valueIn, AdapterOptions options) 8 | { 9 | return (Exception)valueIn == null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/5_Validation/ExceptionValidationAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 648b01212f541764bbafcbc53c88ae58 3 | timeCreated: 1488777168 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/5_Validation/Float To String Adapter Options.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: 4dcbd12f2f1c4404093187b7d99dd456, type: 3} 12 | m_Name: Float To String Adapter Options 13 | m_EditorClassIdentifier: 14 | Format: 0.0 15 | -------------------------------------------------------------------------------- /Assets/5_Validation/Float To String Adapter Options.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c0b8e4ef384ef74b846f3dc74202e1e 3 | timeCreated: 1488869172 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/5_Validation/ValidationViewModel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using UnityWeld.Binding; 4 | 5 | namespace ValidationExample 6 | { 7 | [Binding] 8 | public class ValidationViewModel : MonoBehaviour, INotifyPropertyChanged 9 | { 10 | /// 11 | /// Value of the slider. 12 | /// 13 | private float sliderValue = 2.5f; 14 | 15 | /// 16 | /// Tracks when the text value is valid. 17 | /// 18 | private bool isValid = true; 19 | 20 | /// 21 | /// Cube that rotates based on the sliders 22 | /// 23 | private GameObject rotatingCube; 24 | 25 | /// 26 | /// Value of the slider. 27 | /// 28 | [Binding] 29 | public float SliderValue 30 | { 31 | get 32 | { 33 | return sliderValue; 34 | } 35 | set 36 | { 37 | if (sliderValue == value) 38 | { 39 | return; // No change. 40 | } 41 | 42 | sliderValue = value; 43 | 44 | rotatingCube.transform.localEulerAngles = new Vector3(0f, sliderValue, 0f); 45 | 46 | OnPropertyChanged("SliderValue"); 47 | } 48 | } 49 | 50 | /// 51 | /// Set to true whent the slider value input by the user is valid. 52 | /// 53 | [Binding] 54 | public bool IsValid 55 | { 56 | get 57 | { 58 | return isValid; 59 | } 60 | set 61 | { 62 | if (isValid == value) 63 | { 64 | return; 65 | } 66 | 67 | isValid = value; 68 | 69 | OnPropertyChanged("IsValid"); 70 | } 71 | } 72 | 73 | /// 74 | /// Event to raise when a property's value has changed. 75 | /// 76 | public event PropertyChangedEventHandler PropertyChanged; 77 | 78 | // Use this for initialization 79 | void Start() 80 | { 81 | rotatingCube = GameObject.Find("Cube"); 82 | rotatingCube.transform.localEulerAngles = new Vector3(0f, sliderValue, 0f); //todo: Need a vector adaptor. 83 | } 84 | 85 | // Update is called once per frame 86 | void Update() 87 | { 88 | } 89 | 90 | private void OnPropertyChanged(string propertyName) 91 | { 92 | if (PropertyChanged != null) 93 | { 94 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 95 | } 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Assets/5_Validation/ValidationViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cebaea8087539bc4eb9a0c455b46b8f2 3 | timeCreated: 1476337252 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/5_Validation/validation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e24cd0b3da993d142a63adf659e63eee 3 | timeCreated: 1476337171 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/6_Sliders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 855125e7b35e60145889fe33fa98d3c1 3 | folderAsset: yes 4 | timeCreated: 1479086240 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/6_Sliders/MyViewModel6.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using UnityWeld.Binding; 4 | 5 | [Binding] 6 | public class MyViewModel6 : MonoBehaviour, INotifyPropertyChanged 7 | { 8 | /// 9 | /// Value of the slider. 10 | /// 11 | private float sliderValue = 2.5f; 12 | 13 | /// 14 | /// Tracks when the text value is valid. 15 | /// 16 | private bool isValid = true; 17 | 18 | /// 19 | /// Cube that rotates based on the sliders 20 | /// 21 | private GameObject rotatingCube; 22 | 23 | /// 24 | /// Value of the slider. 25 | /// 26 | [Binding] 27 | public float SliderValue 28 | { 29 | get 30 | { 31 | return sliderValue; 32 | } 33 | set 34 | { 35 | if (sliderValue == value) 36 | { 37 | return; // No change. 38 | } 39 | 40 | sliderValue = value; 41 | rotatingCube.transform.localEulerAngles = new Vector3(0f, sliderValue, 0f); 42 | 43 | OnPropertyChanged("SliderValue"); 44 | } 45 | } 46 | 47 | /// 48 | /// Set to true whent the slider value input by the user is valid. 49 | /// 50 | [Binding] 51 | public bool IsValid 52 | { 53 | get 54 | { 55 | return isValid; 56 | } 57 | set 58 | { 59 | if (isValid == value) 60 | { 61 | return; 62 | } 63 | 64 | isValid = value; 65 | 66 | OnPropertyChanged("IsValid"); 67 | } 68 | } 69 | 70 | /// 71 | /// Event to raise when a property's value has changed. 72 | /// 73 | public event PropertyChangedEventHandler PropertyChanged; 74 | 75 | // Use this for initialization 76 | void Start() 77 | { 78 | rotatingCube = GameObject.Find("Cube"); 79 | rotatingCube.transform.localEulerAngles = new Vector3(0f, sliderValue, 0f); //todo: Need a vector adaptor. 80 | } 81 | 82 | // Update is called once per frame 83 | void Update() 84 | { 85 | } 86 | 87 | private void OnPropertyChanged(string propertyName) 88 | { 89 | if (PropertyChanged != null) 90 | { 91 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Assets/6_Sliders/MyViewModel6.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: def63f38e1441fc4282aa697e1ae24a9 3 | timeCreated: 1479086243 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/6_Sliders/Sliders.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9c55e1aba8ca2545921e3f031981188 3 | timeCreated: 1479084928 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/7_Dropdown.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 156480170d1dffe4bb268a32c8e2cfd7 3 | folderAsset: yes 4 | timeCreated: 1479086240 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/7_Dropdown/Dropdown.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b83e1e202ab3cba48b27356f9fff9460 3 | timeCreated: 1473810929 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/7_Dropdown/MyViewModel7.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using UnityWeld.Binding; 4 | 5 | [Binding] 6 | public class MyViewModel7 : MonoBehaviour, INotifyPropertyChanged 7 | { 8 | private string[] options = new string[] 9 | { 10 | "Option-A", 11 | "Option-B", 12 | "Option-C" 13 | }; 14 | 15 | private string selectedItem = "Option-B"; 16 | 17 | [Binding] 18 | public string SelectedItem 19 | { 20 | get 21 | { 22 | return selectedItem; 23 | } 24 | set 25 | { 26 | if (selectedItem == value) 27 | { 28 | return; // No change. 29 | } 30 | 31 | selectedItem = value; 32 | 33 | OnPropertyChanged("SelectedItem"); 34 | } 35 | } 36 | 37 | public string[] Options 38 | { 39 | get 40 | { 41 | return options; 42 | } 43 | } 44 | 45 | /// 46 | /// Event to raise when a property's value has changed. 47 | /// 48 | public event PropertyChangedEventHandler PropertyChanged; 49 | 50 | // Use this for initialization 51 | void Start() 52 | { 53 | 54 | } 55 | 56 | // Update is called once per frame 57 | void Update() 58 | { 59 | } 60 | 61 | private void OnPropertyChanged(string propertyName) 62 | { 63 | if (PropertyChanged != null) 64 | { 65 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Assets/7_Dropdown/MyViewModel7.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63489ef16ba06a0469be9c068c63349a 3 | timeCreated: 1479086241 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Collection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d46d459ded413f468c06e6321e032a9 3 | folderAsset: yes 4 | timeCreated: 1473390239 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Collection/Collection.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7289ed83151b2a47b5efc33bdaafbca 3 | timeCreated: 1473390239 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Collection/ItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using UnityWeld.Binding; 2 | 3 | /// 4 | /// View-model for items displayed in the collection. 5 | /// 6 | [Binding] 7 | public class ItemViewModel 8 | { 9 | [Binding] 10 | public string DisplayText 11 | { 12 | get; 13 | private set; 14 | } 15 | 16 | public ItemViewModel(string displayText) 17 | { 18 | this.DisplayText = displayText; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Assets/Collection/ItemViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e49349d383db1ce49a23f6aeb430049a 3 | timeCreated: 1473390707 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Collection/MyUI3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using UnityWeld.Binding; 4 | 5 | [Binding] 6 | public class MyUI3 : MonoBehaviour, INotifyPropertyChanged 7 | { 8 | private ObservableList items = new ObservableList() 9 | { 10 | new ItemViewModel("1"), 11 | new ItemViewModel("2"), 12 | new ItemViewModel("3") 13 | }; 14 | 15 | [Binding] 16 | public ObservableList Items 17 | { 18 | get 19 | { 20 | return items; 21 | } 22 | } 23 | 24 | 25 | /// 26 | /// Event to raise when a property's value has changed. 27 | /// 28 | public event PropertyChangedEventHandler PropertyChanged; 29 | 30 | // Use this for initialization 31 | void Start() 32 | { 33 | 34 | } 35 | 36 | // Update is called once per frame 37 | void Update() 38 | { 39 | } 40 | 41 | private void OnPropertyChanged(string propertyName) 42 | { 43 | if (PropertyChanged != null) 44 | { 45 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Assets/Collection/MyUI3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c46fe70474629d74a946cc3483578b00 3 | timeCreated: 1473390427 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SubViewModelBinding.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a1cabcf143d42a4db109c8de3672fd1 3 | folderAsset: yes 4 | timeCreated: 1494223648 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SubViewModelBinding/ColorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityWeld.Binding; 5 | 6 | /// 7 | /// View model for controlling the color of a mesh. 8 | /// 9 | [Binding] 10 | public class ColorViewModel 11 | { 12 | private Material mat; 13 | 14 | public ColorViewModel(MeshRenderer mesh) 15 | { 16 | mat = mesh.material; 17 | } 18 | 19 | /// 20 | /// The red component of the mesh's color. 21 | /// 22 | [Binding] 23 | public float Red 24 | { 25 | get 26 | { 27 | return mat.color.r; 28 | } 29 | set 30 | { 31 | var color = mat.color; 32 | color.r = value; 33 | mat.color = color; 34 | } 35 | } 36 | 37 | /// 38 | /// The green component of the mesh's color. 39 | /// 40 | [Binding] 41 | public float Green 42 | { 43 | get 44 | { 45 | return mat.color.g; 46 | } 47 | set 48 | { 49 | var color = mat.color; 50 | color.g = value; 51 | mat.color = color; 52 | } 53 | } 54 | 55 | /// 56 | /// The blue component of the mesh's color. 57 | /// 58 | [Binding] 59 | public float Blue 60 | { 61 | get 62 | { 63 | return mat.color.b; 64 | } 65 | set 66 | { 67 | var color = mat.color; 68 | color.b = value; 69 | mat.color = color; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Assets/SubViewModelBinding/ColorViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c140fd3069c2a84898f6475d4ee4c2e 3 | timeCreated: 1494224308 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SubViewModelBinding/ObjectViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Assertions; 5 | using UnityWeld.Binding; 6 | 7 | [Binding] 8 | public class ObjectViewModel : MonoBehaviour 9 | { 10 | /// 11 | /// The object we want to manipulate. 12 | /// 13 | public MeshRenderer obj; 14 | 15 | private ColorViewModel colorViewModel; 16 | 17 | /// 18 | /// Sub-view model for controlling the color of the object. 19 | /// 20 | [Binding] 21 | public ColorViewModel SubViewModel 22 | { 23 | get 24 | { 25 | // Lazily initialize the color view model. 26 | if (colorViewModel == null) 27 | { 28 | colorViewModel = new ColorViewModel(obj); 29 | } 30 | 31 | return colorViewModel; 32 | } 33 | } 34 | 35 | /// 36 | /// Property for controlling the object's rotation about the Y axis. 37 | /// 38 | [Binding] 39 | public float Rotation 40 | { 41 | get 42 | { 43 | return obj.transform.localRotation.eulerAngles.y; 44 | } 45 | set 46 | { 47 | obj.transform.localRotation = Quaternion.AngleAxis(value, Vector3.up); 48 | } 49 | } 50 | 51 | private void Awake() 52 | { 53 | Assert.IsNotNull(obj); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/SubViewModelBinding/ObjectViewModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eff0d8a166d26b74ba1bf4d20e5dbeb4 3 | timeCreated: 1494224041 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SubViewModelBinding/SubViewModelBinding.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be10eeb7e8e1ac44f8d2c42977187cfb 3 | timeCreated: 1494223817 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Template_selector.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 252302cb705b0d34f99a0c362e8c2b3d 3 | folderAsset: yes 4 | timeCreated: 1473660946 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Template_selector/AddressTab.cs: -------------------------------------------------------------------------------- 1 | using UnityWeld.Binding; 2 | 3 | namespace TemplateExample 4 | { 5 | [Binding] 6 | public class AddressTab: Tab { 7 | 8 | [Binding] 9 | public string Number 10 | { 11 | get 12 | { 13 | return number; 14 | } 15 | set 16 | { 17 | if (number == value) 18 | { 19 | return; 20 | } 21 | 22 | number = value; 23 | 24 | OnPropertyChanged("Number"); 25 | } 26 | } 27 | private string number = string.Empty; 28 | 29 | [Binding] 30 | public string Street 31 | { 32 | get 33 | { 34 | return street; 35 | } 36 | set 37 | { 38 | if (street == value) 39 | { 40 | return; 41 | } 42 | 43 | street = value; 44 | 45 | OnPropertyChanged("Street"); 46 | } 47 | } 48 | private string street = string.Empty; 49 | 50 | [Binding] 51 | public string Suburb 52 | { 53 | get 54 | { 55 | return suburb; 56 | } 57 | set 58 | { 59 | if (suburb == value) 60 | { 61 | return; 62 | } 63 | 64 | suburb = value; 65 | 66 | OnPropertyChanged("Suburb"); 67 | } 68 | } 69 | private string suburb = string.Empty; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Assets/Template_selector/AddressTab.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1eeb4827b71772d4fbd3a4088110b74a 3 | timeCreated: 1473661620 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Template_selector/MyUI5.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.ComponentModel; 3 | using TemplateExample; 4 | using UnityWeld.Binding; 5 | 6 | [Binding] 7 | public class MyUI5 : MonoBehaviour, INotifyPropertyChanged { 8 | 9 | [Binding] 10 | public NameTab NameTab 11 | { 12 | get 13 | { 14 | return nameTab; 15 | } 16 | } 17 | private NameTab nameTab = new NameTab(); 18 | 19 | [Binding] 20 | public AddressTab AddressTab 21 | { 22 | get 23 | { 24 | return addressTab; 25 | } 26 | } 27 | private AddressTab addressTab = new AddressTab(); 28 | 29 | [Binding] 30 | public Tab ActiveTab 31 | { 32 | get 33 | { 34 | // Lazy init 35 | if (activeTab == null) 36 | { 37 | activeTab = NameTab; 38 | } 39 | 40 | return activeTab; 41 | } 42 | set 43 | { 44 | if (activeTab == value) 45 | { 46 | return; 47 | } 48 | 49 | activeTab = value; 50 | 51 | OnPropertyChanged("ActiveTab"); 52 | } 53 | } 54 | private Tab activeTab = null; 55 | 56 | [Binding] 57 | public void ActivateNameTab() 58 | { 59 | ActiveTab = nameTab; 60 | } 61 | 62 | [Binding] 63 | public void ActivateAddressTab() 64 | { 65 | ActiveTab = addressTab; 66 | } 67 | 68 | public event PropertyChangedEventHandler PropertyChanged; 69 | 70 | private void OnPropertyChanged(string propertyName) 71 | { 72 | if (PropertyChanged != null) 73 | { 74 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Assets/Template_selector/MyUI5.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a078a6507721cc4b9298342cd1f942c 3 | timeCreated: 1473661198 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Template_selector/NameTab.cs: -------------------------------------------------------------------------------- 1 | using UnityWeld.Binding; 2 | 3 | [Binding] 4 | public class NameTab: Tab { 5 | 6 | [Binding] 7 | public string FirstName 8 | { 9 | get 10 | { 11 | return firstName; 12 | } 13 | set 14 | { 15 | if (firstName == value) 16 | { 17 | return; 18 | } 19 | 20 | firstName = value; 21 | 22 | OnPropertyChanged("FirstName"); 23 | } 24 | } 25 | private string firstName = string.Empty; 26 | 27 | [Binding] 28 | public string LastName 29 | { 30 | get 31 | { 32 | return lastName; 33 | } 34 | set 35 | { 36 | if (lastName == value) 37 | { 38 | return; 39 | } 40 | 41 | lastName = value; 42 | 43 | OnPropertyChanged("LastName"); 44 | } 45 | } 46 | private string lastName = string.Empty; 47 | } 48 | -------------------------------------------------------------------------------- /Assets/Template_selector/NameTab.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ebd346e7b577f5498b5d83d3bb9f823 3 | timeCreated: 1473661605 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Template_selector/Tab.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | public abstract class Tab: INotifyPropertyChanged 4 | { 5 | public event PropertyChangedEventHandler PropertyChanged; 6 | 7 | protected void OnPropertyChanged(string propertyName) 8 | { 9 | if (PropertyChanged != null) 10 | { 11 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Template_selector/Tab.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 213a8b2d0cf1ba0428e3811b35aff3be 3 | timeCreated: 1473661796 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Template_selector/Template_selector.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe82c7ceaea5d0b41b49fca1c15193b1 3 | timeCreated: 1473661039 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Unity-Weld.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07a4fadeb99d3e94990e10798e96e212 3 | folderAsset: yes 4 | timeCreated: 1473210816 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c39c732a895ca1847b5f244a7f9c8dc0 3 | folderAsset: yes 4 | timeCreated: 1488238946 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/BaseBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d9cbd40713f37849873cbde35ad9e7e 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/CollectionBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityWeld.Binding; 4 | using UnityWeld.Binding.Internal; 5 | 6 | namespace UnityWeld_Editor 7 | { 8 | [CustomEditor(typeof(CollectionBinding))] 9 | class CollectionBindingEditor : BaseBindingEditor 10 | { 11 | private CollectionBinding targetScript; 12 | 13 | private bool viewModelPrefabModified; 14 | private bool templatesRootPrefabModified; 15 | 16 | private void OnEnable() 17 | { 18 | // Initialise everything 19 | targetScript = (CollectionBinding)target; 20 | } 21 | 22 | public override void OnInspectorGUI() 23 | { 24 | UpdatePrefabModifiedProperties(); 25 | 26 | var defaultLabelStyle = EditorStyles.label.fontStyle; 27 | EditorStyles.label.fontStyle = viewModelPrefabModified ? FontStyle.Bold : defaultLabelStyle; 28 | 29 | ShowViewModelPropertyMenu( 30 | new GUIContent("View-model property", "Property on the view-model to bind to."), 31 | TypeResolver.FindBindableCollectionProperties(targetScript), 32 | updatedValue => targetScript.ViewModelPropertyName = updatedValue, 33 | targetScript.ViewModelPropertyName, 34 | property => true 35 | ); 36 | 37 | EditorStyles.label.fontStyle = templatesRootPrefabModified ? FontStyle.Bold : defaultLabelStyle; 38 | 39 | UpdateProperty( 40 | updatedValue => targetScript.TemplatesRoot = updatedValue, 41 | targetScript.TemplatesRoot, 42 | (GameObject)EditorGUILayout.ObjectField( 43 | new GUIContent("Collection templates", "Parent object for all templates to copy and bind to items in the collection."), 44 | targetScript.TemplatesRoot, 45 | typeof(GameObject), 46 | true 47 | ), 48 | "Set collection templates root" 49 | ); 50 | 51 | EditorStyles.label.fontStyle = defaultLabelStyle; 52 | } 53 | 54 | /// 55 | /// Check whether each of the properties on the object have been changed from the value in the prefab. 56 | /// 57 | private void UpdatePrefabModifiedProperties() 58 | { 59 | var property = serializedObject.GetIterator(); 60 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 61 | // will iterate through the properties. 62 | property.Next(true); 63 | do 64 | { 65 | switch (property.name) 66 | { 67 | case "viewModelPropertyName": 68 | viewModelPrefabModified = property.prefabOverride; 69 | break; 70 | 71 | case "templatesRoot": 72 | templatesRootPrefabModified = property.prefabOverride; 73 | break; 74 | 75 | default: 76 | break; 77 | } 78 | } 79 | while (property.Next(false)); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/CollectionBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2469ac8c42fd1747ac3e8223dff0b53 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/EventBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityWeld.Binding; 6 | using UnityWeld.Binding.Internal; 7 | 8 | namespace UnityWeld_Editor 9 | { 10 | [CustomEditor(typeof(EventBinding))] 11 | public class EventBindingEditor : BaseBindingEditor 12 | { 13 | private EventBinding targetScript; 14 | 15 | // Whether or not the values on our target match its prefab. 16 | private bool viewEventPrefabModified; 17 | private bool viewModelMethodPrefabModified; 18 | 19 | private void OnEnable() 20 | { 21 | targetScript = (EventBinding)target; 22 | } 23 | 24 | public override void OnInspectorGUI() 25 | { 26 | UpdatePrefabModifiedProperties(); 27 | 28 | var defaultLabelStyle = EditorStyles.label.fontStyle; 29 | EditorStyles.label.fontStyle = viewEventPrefabModified ? FontStyle.Bold : defaultLabelStyle; 30 | 31 | ShowEventMenu( 32 | UnityEventWatcher.GetBindableEvents(targetScript.gameObject) 33 | .OrderBy(evt => evt.Name) 34 | .ToArray(), 35 | updatedValue => targetScript.ViewEventName = updatedValue, 36 | targetScript.ViewEventName 37 | ); 38 | 39 | EditorStyles.label.fontStyle = viewModelMethodPrefabModified ? FontStyle.Bold : defaultLabelStyle; 40 | 41 | ShowMethodMenu(targetScript, TypeResolver.FindBindableMethods(targetScript)); 42 | 43 | EditorStyles.label.fontStyle = defaultLabelStyle; 44 | } 45 | 46 | /// 47 | /// Draws the dropdown for selecting a method from bindableViewModelMethods 48 | /// 49 | private void ShowMethodMenu(EventBinding targetScript, BindableMember[] bindableMethods) 50 | { 51 | var tooltip = "Method on the view-model to bind to."; 52 | 53 | InspectorUtils.DoPopup( 54 | new GUIContent(targetScript.ViewModelMethodName), 55 | new GUIContent("View-model method", tooltip), 56 | m => m.ViewModelType + "/" + m.MemberName, 57 | m => true, 58 | m => m.ToString() == targetScript.ViewModelMethodName, 59 | m => UpdateProperty( 60 | updatedValue => targetScript.ViewModelMethodName = updatedValue, 61 | targetScript.ViewModelMethodName, 62 | m.ToString(), 63 | "Set bound view-model method" 64 | ), 65 | bindableMethods 66 | .OrderBy(m => m.ViewModelTypeName) 67 | .ThenBy(m => m.MemberName) 68 | .ToArray() 69 | ); 70 | } 71 | 72 | /// 73 | /// Check whether each of the properties on the object have been changed from the value in the prefab. 74 | /// 75 | private void UpdatePrefabModifiedProperties() 76 | { 77 | var property = serializedObject.GetIterator(); 78 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 79 | // will iterate through the properties. 80 | property.Next(true); 81 | do 82 | { 83 | switch (property.name) 84 | { 85 | case "viewEventName": 86 | viewEventPrefabModified = property.prefabOverride; 87 | break; 88 | 89 | case "viewModelMethodName": 90 | viewModelMethodPrefabModified = property.prefabOverride; 91 | break; 92 | 93 | default: 94 | break; 95 | } 96 | } 97 | while (property.Next(false)); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/EventBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dad6d6dfc9d2a134e9d8053c8c73daad 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/InspectorUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditor.SceneManagement; 4 | using UnityEngine; 5 | 6 | namespace UnityWeld_Editor 7 | { 8 | /// 9 | /// Common utilities for custom inspectors. 10 | /// 11 | internal class InspectorUtils 12 | { 13 | /// 14 | /// Show a popup menu with some items disabled and a label to its left. 15 | /// 16 | public static void DoPopup( 17 | GUIContent content, 18 | GUIContent label, 19 | Func menuName, 20 | Func menuEnabled, 21 | Func isSelected, 22 | Action callback, 23 | T[] items) 24 | { 25 | var labelRect = EditorGUILayout.GetControlRect(false, 16f, EditorStyles.popup); 26 | var controlId = GUIUtility.GetControlID(FocusType.Keyboard, labelRect); 27 | 28 | var buttonRect = EditorGUI.PrefixLabel(labelRect, controlId, label); 29 | 30 | ShowPopupButton( 31 | buttonRect, 32 | labelRect, 33 | controlId, 34 | content, 35 | () => ShowMenu(menuName, menuEnabled, isSelected, callback, items, buttonRect) 36 | ); 37 | } 38 | 39 | /// 40 | /// Shows the button for a popup/dropdown control, with a label. 41 | /// 42 | private static void ShowPopupButton(Rect buttonRect, Rect labelRect, int controlId, GUIContent currentlySelected, Action popup) 43 | { 44 | var currentEvent = Event.current; 45 | var eventType = currentEvent.type; 46 | var style = EditorStyles.popup; 47 | 48 | switch (eventType) 49 | { 50 | case EventType.KeyDown: 51 | if (MainActionKeyForControl(currentEvent, controlId)) 52 | { 53 | popup(); 54 | currentEvent.Use(); 55 | } 56 | break; 57 | 58 | case EventType.Repaint: 59 | style.Draw(buttonRect, currentlySelected, controlId, false); 60 | break; 61 | 62 | case EventType.MouseDown: 63 | if (currentEvent.button != 0) 64 | { 65 | return; 66 | } 67 | 68 | if (buttonRect.Contains(currentEvent.mousePosition)) 69 | { 70 | popup(); 71 | GUIUtility.keyboardControl = controlId; 72 | currentEvent.Use(); 73 | } 74 | else if (labelRect.Contains(currentEvent.mousePosition)) 75 | { 76 | GUIUtility.keyboardControl = controlId; 77 | currentEvent.Use(); 78 | } 79 | break; 80 | 81 | default: 82 | break; 83 | } 84 | } 85 | 86 | /// 87 | /// Returns whether the specified control has been activated by a key press. 88 | /// 89 | private static bool MainActionKeyForControl(Event evt, int controlId) 90 | { 91 | if (GUIUtility.keyboardControl != controlId) 92 | { 93 | return false; 94 | } 95 | bool modifierPressed = evt.alt || evt.shift || evt.command || evt.control; 96 | if (!modifierPressed && evt.type == EventType.KeyDown && evt.character == ' ') 97 | { 98 | evt.Use(); 99 | return false; 100 | } 101 | return evt.type == EventType.KeyDown 102 | && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter) 103 | && !modifierPressed; 104 | } 105 | 106 | /// 107 | /// Show a menu with some items disabled. Has a callback that will be called when an item is selected with the index of the selected item. 108 | /// Takes a dictionary of options and whether or not they should be enabled. 109 | /// 110 | private static void ShowMenu(Func menuName, Func menuEnabled, Func isSelected, Action callback, T[] items, Rect position) 111 | { 112 | var menu = new GenericMenu(); 113 | 114 | for (var i = 0; i < items.Length; i++) 115 | { 116 | // Need to cache index so that it doesn't get passed through to the callback by reference. 117 | int index = i; 118 | var item = items[index]; 119 | 120 | var content = new GUIContent(menuName(item)); 121 | 122 | if (menuEnabled(item)) 123 | { 124 | menu.AddItem(content, isSelected(item), () => callback(item)); 125 | } 126 | else 127 | { 128 | menu.AddDisabledItem(content); 129 | } 130 | } 131 | 132 | menu.DropDown(position); 133 | } 134 | 135 | /// 136 | /// Tell Unity that a change has been made to a specified object and we have to save the scene. 137 | /// 138 | public static void MarkSceneDirty(GameObject gameObject) 139 | { 140 | // TODO: Undo.RecordObject also marks the scene dirty, so this will no longer be necessary once undo support is added. 141 | EditorSceneManager.MarkSceneDirty(gameObject.scene); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/InspectorUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cba09f4eac84c364596328b0946a92b9 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/OneWayPropertyBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEditor; 4 | using UnityEditor.AnimatedValues; 5 | using UnityEngine; 6 | using UnityWeld.Binding; 7 | using UnityWeld.Binding.Internal; 8 | 9 | namespace UnityWeld_Editor 10 | { 11 | [CustomEditor(typeof(OneWayPropertyBinding))] 12 | class OneWayPropertyBindingEditor : BaseBindingEditor 13 | { 14 | private OneWayPropertyBinding targetScript; 15 | 16 | private AnimBool viewAdapterOptionsFade; 17 | 18 | // Whether each property in the target differs from the prefab it uses. 19 | private bool viewAdapterPrefabModified; 20 | private bool viewAdapterOptionsPrefabModified; 21 | private bool viewModelPropertyPrefabModified; 22 | private bool viewPropertyPrefabModified; 23 | 24 | private void OnEnable() 25 | { 26 | // Initialise reference to target script 27 | targetScript = (OneWayPropertyBinding)target; 28 | 29 | Type adapterType; 30 | 31 | viewAdapterOptionsFade = new AnimBool( 32 | ShouldShowAdapterOptions(targetScript.ViewAdapterTypeName, out adapterType) 33 | ); 34 | 35 | viewAdapterOptionsFade.valueChanged.AddListener(Repaint); 36 | } 37 | 38 | private void OnDisable() 39 | { 40 | viewAdapterOptionsFade.valueChanged.RemoveListener(Repaint); 41 | } 42 | 43 | public override void OnInspectorGUI() 44 | { 45 | UpdatePrefabModifiedProperties(); 46 | 47 | var defaultLabelStyle = EditorStyles.label.fontStyle; 48 | EditorStyles.label.fontStyle = viewPropertyPrefabModified 49 | ? FontStyle.Bold 50 | : defaultLabelStyle; 51 | 52 | Type viewPropertyType; 53 | ShowViewPropertyMenu( 54 | new GUIContent("View property", "Property on the view to bind to"), 55 | PropertyFinder.GetBindableProperties(targetScript.gameObject) 56 | .OrderBy(prop => prop.ViewModelTypeName) 57 | .ThenBy(prop => prop.MemberName) 58 | .ToArray(), 59 | updatedValue => targetScript.ViewPropertyName = updatedValue, 60 | targetScript.ViewPropertyName, 61 | out viewPropertyType 62 | ); 63 | 64 | // Don't let the user set anything else until they've chosen a view property. 65 | var guiPreviouslyEnabled = GUI.enabled; 66 | if (string.IsNullOrEmpty(targetScript.ViewPropertyName)) 67 | { 68 | GUI.enabled = false; 69 | } 70 | 71 | var viewAdapterTypeNames = GetAdapterTypeNames( 72 | type => viewPropertyType == null || 73 | TypeResolver.FindAdapterAttribute(type).OutputType == viewPropertyType 74 | ); 75 | 76 | EditorStyles.label.fontStyle = viewAdapterPrefabModified 77 | ? FontStyle.Bold 78 | : defaultLabelStyle; 79 | 80 | ShowAdapterMenu( 81 | new GUIContent( 82 | "View adapter", 83 | "Adapter that converts values sent from the view-model to the view." 84 | ), 85 | viewAdapterTypeNames, 86 | targetScript.ViewAdapterTypeName, 87 | newValue => 88 | { 89 | // Get rid of old adapter options if we changed the type of the adapter. 90 | if (newValue != targetScript.ViewAdapterTypeName) 91 | { 92 | Undo.RecordObject(targetScript, "Set view adapter options"); 93 | targetScript.ViewAdapterOptions = null; 94 | } 95 | 96 | UpdateProperty( 97 | updatedValue => targetScript.ViewAdapterTypeName = updatedValue, 98 | targetScript.ViewAdapterTypeName, 99 | newValue, 100 | "Set view adapter" 101 | ); 102 | } 103 | ); 104 | 105 | Type adapterType; 106 | viewAdapterOptionsFade.target = ShouldShowAdapterOptions( 107 | targetScript.ViewAdapterTypeName, 108 | out adapterType 109 | ); 110 | 111 | EditorStyles.label.fontStyle = viewAdapterOptionsPrefabModified 112 | ? FontStyle.Bold 113 | : defaultLabelStyle; 114 | 115 | ShowAdapterOptionsMenu( 116 | "View adapter options", 117 | adapterType, 118 | options => targetScript.ViewAdapterOptions = options, 119 | targetScript.ViewAdapterOptions, 120 | viewAdapterOptionsFade.faded 121 | ); 122 | 123 | EditorGUILayout.Space(); 124 | 125 | EditorStyles.label.fontStyle = viewModelPropertyPrefabModified 126 | ? FontStyle.Bold 127 | : defaultLabelStyle; 128 | 129 | var adaptedViewPropertyType = AdaptTypeBackward( 130 | viewPropertyType, 131 | targetScript.ViewAdapterTypeName 132 | ); 133 | ShowViewModelPropertyMenu( 134 | new GUIContent( 135 | "View-model property", 136 | "Property on the view-model to bind to." 137 | ), 138 | TypeResolver.FindBindableProperties(targetScript), 139 | updatedValue => targetScript.ViewModelPropertyName = updatedValue, 140 | targetScript.ViewModelPropertyName, 141 | property => property.PropertyType == adaptedViewPropertyType 142 | ); 143 | 144 | GUI.enabled = guiPreviouslyEnabled; 145 | 146 | EditorStyles.label.fontStyle = defaultLabelStyle; 147 | } 148 | 149 | /// 150 | /// Check whether each of the properties on the object have been changed 151 | /// from the value in the prefab. 152 | /// 153 | private void UpdatePrefabModifiedProperties() 154 | { 155 | var property = serializedObject.GetIterator(); 156 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 157 | // will iterate through the properties. 158 | property.Next(true); 159 | do 160 | { 161 | switch (property.name) 162 | { 163 | case "viewAdapterTypeName": 164 | viewAdapterPrefabModified = property.prefabOverride; 165 | break; 166 | 167 | case "viewAdapterOptions": 168 | viewAdapterOptionsPrefabModified = property.prefabOverride; 169 | break; 170 | 171 | case "viewModelPropertyName": 172 | viewModelPropertyPrefabModified = property.prefabOverride; 173 | break; 174 | 175 | case "viewPropertyName": 176 | viewPropertyPrefabModified = property.prefabOverride; 177 | break; 178 | 179 | default: 180 | break; 181 | } 182 | } 183 | while (property.Next(false)); 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/OneWayPropertyBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d6ad63de88033c49ad82b27e4481bae 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/SubViewModelBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using UnityWeld.Binding; 4 | using UnityWeld.Binding.Internal; 5 | using System.Linq; 6 | using System.Reflection; 7 | 8 | namespace UnityWeld_Editor 9 | { 10 | /// 11 | /// Inspector window for SubViewModelBinding 12 | /// 13 | [CustomEditor(typeof(SubViewModelBinding))] 14 | public class SubViewModelBindingEditor : BaseBindingEditor 15 | { 16 | private SubViewModelBinding targetScript; 17 | 18 | /// 19 | /// Whether or not the value on our target matches its prefab. 20 | /// 21 | private bool propertyPrefabModified; 22 | 23 | private void OnEnable() 24 | { 25 | targetScript = (SubViewModelBinding)target; 26 | } 27 | 28 | public override void OnInspectorGUI() 29 | { 30 | UpdatePrefabModifiedProperties(); 31 | 32 | var bindableProperties = FindBindableProperties(); 33 | 34 | var defaultLabelStyle = EditorStyles.label.fontStyle; 35 | EditorStyles.label.fontStyle = propertyPrefabModified 36 | ? FontStyle.Bold 37 | : defaultLabelStyle; 38 | 39 | ShowViewModelPropertyMenu( 40 | new GUIContent( 41 | "Sub view-model property", 42 | "The property on the top level view model containing the sub view-model" 43 | ), 44 | bindableProperties, 45 | updatedValue => 46 | { 47 | targetScript.ViewModelPropertyName = updatedValue; 48 | 49 | targetScript.ViewModelTypeName = bindableProperties 50 | .Where(prop => prop.ToString() == updatedValue) 51 | .Single() 52 | .Member.PropertyType.ToString(); 53 | }, 54 | targetScript.ViewModelPropertyName, 55 | p => true 56 | ); 57 | 58 | EditorStyles.label.fontStyle = defaultLabelStyle; 59 | } 60 | 61 | private BindableMember[] FindBindableProperties() 62 | { 63 | return TypeResolver.FindBindableProperties(targetScript) 64 | .Where(prop => prop.Member.PropertyType 65 | .GetCustomAttributes(typeof(BindingAttribute), false) 66 | .Any() 67 | ) 68 | .ToArray(); 69 | } 70 | 71 | /// 72 | /// Check whether each of the properties on the object have been changed 73 | /// from the value in the prefab. 74 | /// 75 | private void UpdatePrefabModifiedProperties() 76 | { 77 | var property = serializedObject.GetIterator(); 78 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 79 | // will iterate through the properties. 80 | 81 | propertyPrefabModified = false; 82 | property.Next(true); 83 | do 84 | { 85 | switch (property.name) 86 | { 87 | case "viewModelPropertyName": 88 | case "viewModelTypeName": 89 | propertyPrefabModified = property.prefabOverride 90 | || propertyPrefabModified; 91 | break; 92 | 93 | default: 94 | break; 95 | } 96 | } 97 | while (property.Next(false)); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/SubViewModelBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1daac225702cc4046a15229add353a60 3 | timeCreated: 1494225172 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/TemplateBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityWeld.Binding; 4 | using UnityWeld.Binding.Internal; 5 | 6 | namespace UnityWeld_Editor 7 | { 8 | [CustomEditor(typeof(TemplateBinding))] 9 | class TemplateBindingEditor : BaseBindingEditor 10 | { 11 | private TemplateBinding targetScript; 12 | 13 | private bool viewModelPrefabModified; 14 | private bool templatesRootPrefabModified; 15 | 16 | private void OnEnable() 17 | { 18 | targetScript = (TemplateBinding)target; 19 | } 20 | 21 | public override void OnInspectorGUI() 22 | { 23 | UpdatePrefabModifiedProperties(); 24 | 25 | var defaultLabelStyle = EditorStyles.label.fontStyle; 26 | EditorStyles.label.fontStyle = viewModelPrefabModified 27 | ? FontStyle.Bold 28 | : defaultLabelStyle; 29 | 30 | ShowViewModelPropertyMenu( 31 | new GUIContent( 32 | "Template property", 33 | "Property on the view model to use for selecting templates." 34 | ), 35 | TypeResolver.FindBindableProperties(targetScript), 36 | updatedValue => targetScript.ViewModelPropertyName = updatedValue, 37 | targetScript.ViewModelPropertyName, 38 | property => true 39 | ); 40 | 41 | EditorStyles.label.fontStyle = templatesRootPrefabModified 42 | ? FontStyle.Bold 43 | : defaultLabelStyle; 44 | 45 | UpdateProperty( 46 | updatedValue => targetScript.TemplatesRoot = updatedValue, 47 | targetScript.TemplatesRoot, 48 | (GameObject)EditorGUILayout.ObjectField( 49 | new GUIContent( 50 | "Templates root object", 51 | "Parent object to the objects we want to use as templates." 52 | ), 53 | targetScript.TemplatesRoot, 54 | typeof(GameObject), 55 | true 56 | ), 57 | "Set template binding root object" 58 | ); 59 | 60 | EditorStyles.label.fontStyle = defaultLabelStyle; 61 | } 62 | 63 | /// 64 | /// Check whether each of the properties on the object have been changed 65 | /// from the value in the prefab. 66 | /// 67 | private void UpdatePrefabModifiedProperties() 68 | { 69 | var property = serializedObject.GetIterator(); 70 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 71 | // will iterate through the properties. 72 | property.Next(true); 73 | do 74 | { 75 | switch (property.name) 76 | { 77 | case "viewModelPropertyName": 78 | viewModelPrefabModified = property.prefabOverride; 79 | break; 80 | 81 | case "templatesRoot": 82 | templatesRootPrefabModified = property.prefabOverride; 83 | break; 84 | 85 | default: 86 | break; 87 | } 88 | } 89 | while (property.Next(false)); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/TemplateBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f294a0ecb17373b4090ec4df4d326a5e 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/TemplateEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityWeld.Binding; 6 | using UnityWeld.Binding.Internal; 7 | 8 | namespace UnityWeld_Editor 9 | { 10 | /// 11 | /// Editor for template bindings with a dropdown for selecting what view model 12 | /// to bind to. 13 | /// 14 | [CustomEditor(typeof(Template))] 15 | public class TemplateEditor : BaseBindingEditor 16 | { 17 | private Template targetScript; 18 | 19 | /// 20 | /// Whether the value on our target matches its prefab. 21 | /// 22 | private bool propertyPrefabModified; 23 | 24 | private void OnEnable() 25 | { 26 | targetScript = (Template)target; 27 | } 28 | 29 | public override void OnInspectorGUI() 30 | { 31 | UpdatePrefabModifiedProperties(); 32 | 33 | var availableViewModels = TypeResolver.TypesWithBindingAttribute 34 | .Select(type => type.ToString()) 35 | .OrderBy(name => name) 36 | .ToArray(); 37 | 38 | var selectedIndex = Array.IndexOf( 39 | availableViewModels, 40 | targetScript.ViewModelTypeName 41 | ); 42 | 43 | var defaultLabelStyle = EditorStyles.label.fontStyle; 44 | EditorStyles.label.fontStyle = propertyPrefabModified 45 | ? FontStyle.Bold 46 | : defaultLabelStyle; 47 | 48 | var newSelectedIndex = EditorGUILayout.Popup( 49 | new GUIContent( 50 | "Template view model", 51 | "Type of the view model that this template will be bound to when it is instantiated." 52 | ), 53 | selectedIndex, 54 | availableViewModels 55 | .Select(viewModel => new GUIContent(viewModel)) 56 | .ToArray() 57 | ); 58 | 59 | EditorStyles.label.fontStyle = defaultLabelStyle; 60 | 61 | UpdateProperty(newValue => targetScript.ViewModelTypeName = newValue, 62 | selectedIndex < 0 63 | ? string.Empty 64 | : availableViewModels[selectedIndex], 65 | newSelectedIndex < 0 66 | ? string.Empty 67 | : availableViewModels[newSelectedIndex], 68 | "Set bound view-model for template" 69 | ); 70 | } 71 | 72 | /// 73 | /// Check whether each of the properties on the object have been changed from the value in the prefab. 74 | /// 75 | private void UpdatePrefabModifiedProperties() 76 | { 77 | var property = serializedObject.GetIterator(); 78 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 79 | // will iterate through the properties. 80 | property.Next(true); 81 | do 82 | { 83 | if (property.name == "viewModelTypeName") 84 | { 85 | propertyPrefabModified = property.prefabOverride; 86 | } 87 | } 88 | while (property.Next(false)); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/TemplateEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1adb265321353874bb7c71acf1890bc9 3 | timeCreated: 1489473064 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/ToggleActiveBindingEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditor.AnimatedValues; 4 | using UnityEngine; 5 | using UnityWeld.Binding; 6 | using UnityWeld.Binding.Exceptions; 7 | using UnityWeld.Binding.Internal; 8 | 9 | namespace UnityWeld_Editor 10 | { 11 | [CustomEditor(typeof(ToggleActiveBinding))] 12 | public class ToggleActiveBindingEditor : BaseBindingEditor 13 | { 14 | private ToggleActiveBinding targetScript; 15 | 16 | private AnimBool viewAdapterOptionsFade; 17 | 18 | private bool viewAdapterPrefabModified; 19 | private bool viewAdapterOptionsPrefabModified; 20 | private bool viewModelPropertyPrefabModified; 21 | 22 | private void OnEnable() 23 | { 24 | targetScript = (ToggleActiveBinding)target; 25 | 26 | Type adapterType; 27 | 28 | viewAdapterOptionsFade = new AnimBool( 29 | ShouldShowAdapterOptions(targetScript.ViewAdapterTypeName, out adapterType) 30 | ); 31 | 32 | viewAdapterOptionsFade.valueChanged.AddListener(Repaint); 33 | } 34 | 35 | private void OnDisable() 36 | { 37 | viewAdapterOptionsFade.valueChanged.RemoveListener(Repaint); 38 | } 39 | 40 | public override void OnInspectorGUI() 41 | { 42 | UpdatePrefabModifiedProperties(); 43 | 44 | var defaultLabelStyle = EditorStyles.label.fontStyle; 45 | 46 | Type viewPropertyType = typeof(bool); 47 | 48 | var viewAdapterTypeNames = GetAdapterTypeNames( 49 | type => viewPropertyType == null || 50 | TypeResolver.FindAdapterAttribute(type).OutputType == viewPropertyType 51 | ); 52 | 53 | EditorStyles.label.fontStyle = viewAdapterPrefabModified 54 | ? FontStyle.Bold 55 | : defaultLabelStyle; 56 | 57 | ShowAdapterMenu( 58 | new GUIContent( 59 | "View adapter", 60 | "Adapter that converts values sent from the view-model to the view." 61 | ), 62 | viewAdapterTypeNames, 63 | targetScript.ViewAdapterTypeName, 64 | newValue => 65 | { 66 | // Get rid of old adapter options if we changed the type of the adapter. 67 | if (newValue != targetScript.ViewAdapterTypeName) 68 | { 69 | Undo.RecordObject(targetScript, "Set view adapter options"); 70 | targetScript.ViewAdapterOptions = null; 71 | } 72 | 73 | UpdateProperty( 74 | updatedValue => targetScript.ViewAdapterTypeName = updatedValue, 75 | targetScript.ViewAdapterTypeName, 76 | newValue, 77 | "Set view adapter" 78 | ); 79 | } 80 | ); 81 | 82 | Type adapterType; 83 | viewAdapterOptionsFade.target = ShouldShowAdapterOptions( 84 | targetScript.ViewAdapterTypeName, 85 | out adapterType 86 | ); 87 | 88 | EditorStyles.label.fontStyle = viewAdapterOptionsPrefabModified 89 | ? FontStyle.Bold 90 | : defaultLabelStyle; 91 | 92 | ShowAdapterOptionsMenu( 93 | "View adapter options", 94 | adapterType, 95 | options => targetScript.ViewAdapterOptions = options, 96 | targetScript.ViewAdapterOptions, 97 | viewAdapterOptionsFade.faded 98 | ); 99 | 100 | EditorGUILayout.Space(); 101 | 102 | EditorStyles.label.fontStyle = viewModelPropertyPrefabModified 103 | ? FontStyle.Bold 104 | : defaultLabelStyle; 105 | 106 | var adaptedViewPropertyType = AdaptTypeBackward( 107 | viewPropertyType, 108 | targetScript.ViewAdapterTypeName 109 | ); 110 | ShowViewModelPropertyMenu( 111 | new GUIContent( 112 | "View-model property", 113 | "Property on the view-model to bind to." 114 | ), 115 | TypeResolver.FindBindableProperties(targetScript), 116 | updatedValue => targetScript.ViewModelPropertyName = updatedValue, 117 | targetScript.ViewModelPropertyName, 118 | property => property.PropertyType == adaptedViewPropertyType 119 | ); 120 | 121 | EditorStyles.label.fontStyle = defaultLabelStyle; 122 | } 123 | 124 | private void UpdatePrefabModifiedProperties() 125 | { 126 | var property = serializedObject.GetIterator(); 127 | // Need to call Next(true) to get the first child. Once we have it, Next(false) 128 | // will iterate through the properties. 129 | property.Next(true); 130 | do 131 | { 132 | switch (property.name) 133 | { 134 | case "viewAdapterTypeName": 135 | viewAdapterPrefabModified = property.prefabOverride; 136 | break; 137 | 138 | case "viewAdapterOptions": 139 | viewAdapterOptionsPrefabModified = property.prefabOverride; 140 | break; 141 | 142 | case "viewModelPropertyName": 143 | viewModelPropertyPrefabModified = property.prefabOverride; 144 | break; 145 | 146 | default: 147 | break; 148 | } 149 | } 150 | while (property.Next(false)); 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/ToggleActiveBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e3c707ba08018e44bc45e024f1048b8 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/Editor/TwoWayPropertyBindingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0699c6f6b5734a24c97549d38296ea1f 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f1d0cbfcd105d149bc71f631f5708c8 3 | folderAsset: yes 4 | timeCreated: 1488238946 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/AOTOptimisationHelper.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.EventSystems; 3 | using UnityWeld.Binding.Internal; 4 | // ReSharper disable UnusedMember.Global 5 | // ReSharper disable UnusedMember.Local 6 | // ReSharper disable UnusedVariable 7 | 8 | #pragma warning disable 219 // Disable warning that variable is never used 9 | 10 | namespace UnityWeld 11 | { 12 | /// 13 | /// In order for certain generic types to not be optimised-out by IL2CPP for 14 | /// platforms like Xbox One, iPhone and WebGL, we need to reference them at 15 | /// least once in code instead of just calling them via reflection. 16 | /// 17 | /// See this page for more details: 18 | /// https://docs.unity3d.com/Manual/TroubleShootingIPhone.html 19 | /// In the section "The game crashes with the error message “ExecutionEngineException: 20 | /// Attempting to JIT compile method ‘SometType`1<SomeValueType>:.ctor ()’ while 21 | /// running with –aot-only.”" 22 | /// 23 | internal class AOTOptimisationHelper 24 | { 25 | // Even though this method is never called, the fact that it exists will 26 | // ensure the compiler includes the types referenced in it so that we can 27 | // later refer to those via reflection. 28 | private void EnsureGenericTypes() 29 | { 30 | // Used by InputField 31 | var strEventBinder = new UnityEventBinder(null, null); 32 | 33 | // Used by Slider and Scrollbar 34 | var floatEventBinder = new UnityEventBinder(null, null); 35 | 36 | // Used by Toggle 37 | var boolEventBinder = new UnityEventBinder(null, null); 38 | 39 | // Used by Dropdown 40 | var intEventBinder = new UnityEventBinder(null, null); 41 | 42 | // Used by ScrollRect 43 | var vector2EventBinder = new UnityEventBinder(null, null); 44 | 45 | // Used by ColorTween 46 | var colorEventBinder = new UnityEventBinder(null, null); 47 | 48 | // Used by EventTrigger 49 | var baseEventDataEventBinder = new UnityEventBinder(null, null); 50 | } 51 | } 52 | } 53 | 54 | #pragma warning restore 219 -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/AOTOptimisationHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 215bf113025aede4e94f471baa976841 3 | timeCreated: 1491278290 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1a9143e6cdcf994796b700aaa902bab 3 | folderAsset: yes 4 | timeCreated: 1488238946 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/AbstractMemberBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6f1f65b363559c4793ff9989a432762 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/AbstractTemplateSelector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eba08ddb05e47341893eb2b5380e8a4 3 | timeCreated: 1489473064 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/AdapterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding 4 | { 5 | /// 6 | /// Attribute that defines what types an adapter can convert from and to. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 9 | public class AdapterAttribute : Attribute 10 | { 11 | public AdapterAttribute(Type fromType, Type toType) 12 | { 13 | InputType = fromType; 14 | OutputType = toType; 15 | OptionsType = typeof(AdapterOptions); 16 | } 17 | 18 | public AdapterAttribute(Type fromType, Type toType, Type optionsType) 19 | { 20 | InputType = fromType; 21 | OutputType = toType; 22 | OptionsType = optionsType; 23 | } 24 | 25 | public Type InputType { get; private set; } 26 | 27 | public Type OutputType { get; private set; } 28 | 29 | public Type OptionsType { get; private set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/AdapterAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5be38e30824099a479bd28545e2e1cad 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/AdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWeld.Binding 4 | { 5 | /// 6 | /// Base class for adapter options. 7 | /// 8 | public abstract class AdapterOptions : ScriptableObject 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/AdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b04f3da74e7c8574bb462e5f946c7ed4 3 | timeCreated: 1488757774 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b2a4dc3a9a2ace44921b4618c561d53 3 | folderAsset: yes 4 | timeCreated: 1488238946 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolInversionAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding.Adapters 2 | { 3 | /// 4 | /// Adapter that inverts the value of the bound boolean property. 5 | /// 6 | [Adapter(typeof(bool), typeof(bool))] 7 | public class BoolInversionAdapter : IAdapter 8 | { 9 | public object Convert(object valueIn, AdapterOptions options) 10 | { 11 | return !(bool)valueIn; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolInversionAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69291a03c1c26a246bc574d58a752918 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorAdapter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Adapter for converting from a bool to a Unity color. 7 | /// 8 | [Adapter(typeof(bool), typeof(Color), typeof(BoolToColorAdapterOptions))] 9 | public class BoolToColorAdapter : IAdapter 10 | { 11 | public object Convert(object valueIn, AdapterOptions options) 12 | { 13 | var adapterOptions = (BoolToColorAdapterOptions)options; 14 | 15 | return (bool)valueIn ? adapterOptions.TrueColor : adapterOptions.FalseColor; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca87624e7ff431a46a719c473b60fcb3 3 | timeCreated: 1513732861 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorAdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Options for converting from a bool to a Unity color. 7 | /// 8 | [CreateAssetMenu(menuName = "Unity Weld/Adapter options/Bool to Color adapter options")] 9 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 10 | public class BoolToColorAdapterOptions : AdapterOptions 11 | { 12 | /// 13 | /// The value used when the bool is false. 14 | /// 15 | public Color FalseColor; 16 | 17 | /// 18 | /// The value used when the bool is true. 19 | /// 20 | public Color TrueColor; 21 | } 22 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorAdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8190baa0cb74bac439a0e20e2295dd12 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorBlockAdapter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.UI; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Adapter for converting from a bool to a Unity color. 7 | /// 8 | [Adapter(typeof(bool), typeof(ColorBlock), typeof(BoolToColorBlockAdapterOptions))] 9 | public class BoolToColorBlockAdapter : IAdapter 10 | { 11 | public object Convert(object valueIn, AdapterOptions options) 12 | { 13 | var adapterOptions = (BoolToColorBlockAdapterOptions)options; 14 | 15 | return (bool)valueIn ? adapterOptions.TrueColors : adapterOptions.FalseColors; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorBlockAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 065260cf417264e479bf529fa9804ba0 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorBlockAdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace UnityWeld.Binding.Adapters 5 | { 6 | /// 7 | /// Options for converting from a bool to a Unity color. 8 | /// 9 | [CreateAssetMenu(menuName = "Unity Weld/Adapter options/Bool to ColorBlock adapter options")] 10 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 11 | public class BoolToColorBlockAdapterOptions : AdapterOptions 12 | { 13 | /// 14 | /// The value used when the bool is false. 15 | /// 16 | [Header("False colors")] 17 | public ColorBlock FalseColors; 18 | 19 | /// 20 | /// The value used when the bool is true. 21 | /// 22 | [Header("True colors")] 23 | public ColorBlock TrueColors; 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToColorBlockAdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 152e094d26188da4aad2e73419c3ee09 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToStringAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding.Adapters 2 | { 3 | /// 4 | /// Adapter for converting from a bool to a string. 5 | /// 6 | [Adapter(typeof(bool), typeof(string), typeof(BoolToStringAdapterOptions))] 7 | public class BoolToStringAdapter : IAdapter 8 | { 9 | public object Convert(object valueIn, AdapterOptions options) 10 | { 11 | var adapterOptions = (BoolToStringAdapterOptions)options; 12 | 13 | return (bool)valueIn ? adapterOptions.TrueValueString : adapterOptions.FalseValueString; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToStringAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e2e554fc36e9e94cb6336365fdc3081 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToStringAdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Options for converting from a bool to a string. 7 | /// 8 | [CreateAssetMenu(menuName = "Unity Weld/Adapter options/Bool to string adapter")] 9 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 10 | public class BoolToStringAdapterOptions : AdapterOptions 11 | { 12 | /// 13 | /// The value used when the bool is set to true. 14 | /// 15 | public string TrueValueString; 16 | 17 | /// 18 | /// The value used when the bool is set to false. 19 | /// 20 | public string FalseValueString; 21 | } 22 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/BoolToStringAdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17d0403ed2df5a7469988c31afcf48a2 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/DateTimeToStringAdapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Adapter for converting from a DateTime to a string. 7 | /// 8 | [Adapter(typeof(DateTime), typeof(string), typeof(DateTimeToStringAdapterOptions))] 9 | class DateTimeToStringAdapter : IAdapter 10 | { 11 | public object Convert(object valueIn, AdapterOptions options) 12 | { 13 | var dateTime = (DateTime) valueIn; 14 | var adapterOptions = (DateTimeToStringAdapterOptions) options; 15 | return dateTime.ToString(adapterOptions.Format); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/DateTimeToStringAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ababb0953d6d3443ae6211de3febbf1 3 | timeCreated: 1489038817 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/DateTimeToStringAdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Options for converting a DateTime to a string. 7 | /// 8 | [CreateAssetMenu(menuName = "Unity Weld/Adapter options/DateTime to string adapter")] 9 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 10 | public class DateTimeToStringAdapterOptions : AdapterOptions 11 | { 12 | /// 13 | /// Format passed in to the DateTime.ToString method. 14 | /// See this page for details on usage: https://msdn.microsoft.com/en-us/library/zdtaw1bw(v=vs.110).aspx 15 | /// 16 | public string Format; 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/DateTimeToStringAdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78add3cdf1af2024592701a6f4518d1f 3 | timeCreated: 1489038817 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/FloatToStringAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding.Adapters 2 | { 3 | /// 4 | /// Adapter that converts a float to a string. 5 | /// 6 | [Adapter(typeof(float), typeof(string), typeof(FloatToStringAdapterOptions))] 7 | public class FloatToStringAdapter : IAdapter 8 | { 9 | public object Convert(object valueIn, AdapterOptions options) 10 | { 11 | var format = ((FloatToStringAdapterOptions) options).Format; 12 | return ((float)valueIn).ToString(format); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/FloatToStringAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20ea99e3165e4604682f8c978ac6b670 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/FloatToStringAdapterOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWeld.Binding.Adapters 4 | { 5 | /// 6 | /// Options for the float to string adapter. 7 | /// 8 | [CreateAssetMenu(menuName = "Unity Weld/Adapter options/Float to string adapter")] 9 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 10 | public class FloatToStringAdapterOptions : AdapterOptions 11 | { 12 | /// 13 | /// Options passed in to the Single.ToString() method. 14 | /// Defaults to two decimal places. 15 | /// See this page for more details: https://msdn.microsoft.com/en-us/library/f71z6k0c(v=vs.110).aspx 16 | /// 17 | public string Format = "0.00"; 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/FloatToStringAdapterOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4dcbd12f2f1c4404093187b7d99dd456 3 | timeCreated: 1488757774 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/IntToStringAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding.Adapters 2 | { 3 | /// 4 | /// Adapter for converting from an int to a string. 5 | /// 6 | [Adapter(typeof(int), typeof(string))] 7 | public class IntToStringAdapter : IAdapter 8 | { 9 | public object Convert(object valueIn, AdapterOptions options) 10 | { 11 | return ((int)valueIn).ToString(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/IntToStringAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 325c3f81e4c072b4ea102c78f68cb6e0 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/StringToFloatAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding.Adapters 2 | { 3 | /// 4 | /// Adapter that parses a string as a float. 5 | /// 6 | [Adapter(typeof(string), typeof(float))] 7 | public class StringToFloatAdapter : IAdapter 8 | { 9 | public object Convert(object valueIn, AdapterOptions options) 10 | { 11 | return float.Parse((string)valueIn); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/StringToFloatAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1bcb5449eae91e45868db149b64d4f5 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/StringToIntAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding.Adapters 2 | { 3 | /// 4 | /// Adapter for converting from a string to an int. 5 | /// 6 | [Adapter(typeof(string), typeof(int))] 7 | public class StringToIntAdapter : IAdapter 8 | { 9 | public object Convert(object valueIn, AdapterOptions options) 10 | { 11 | return int.Parse((string)valueIn); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Adapters/StringToIntAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2698430e59865b4989404fcb95c1028 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/BindingAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding 4 | { 5 | /// 6 | /// Mark a class, interface, method or property as bindable. Bindable methods and properties must 7 | /// reside within classes or interfaces that have also been marked as bindable. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface, 10 | Inherited = false)] 11 | public class BindingAttribute : Attribute 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/BindingAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8131e2995c35a740bc76f7251af772e 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/BoundObservableList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2570fdef7eea7a343b4d5d0b55e8d037 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/CollectionBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c907d248ac66a341b95f1f58d6bc8d4 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/DropdownBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3c3c10dc919ed3449d137a96b0f2abe 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/EventBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Serialization; 4 | using UnityWeld.Binding.Internal; 5 | 6 | namespace UnityWeld.Binding 7 | { 8 | /// 9 | /// Class for binding Unity UI events to methods in a view model. 10 | /// 11 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 12 | public class EventBinding : AbstractMemberBinding 13 | { 14 | /// 15 | /// Name of the method in the view model to bind to. 16 | /// 17 | public string ViewModelMethodName 18 | { 19 | get { return viewModelMethodName; } 20 | set { viewModelMethodName = value; } 21 | } 22 | 23 | [SerializeField] 24 | private string viewModelMethodName; 25 | 26 | /// 27 | /// Name of the event in the view to bind to. 28 | /// 29 | public string ViewEventName 30 | { 31 | get { return viewEventName; } 32 | set { viewEventName = value; } 33 | } 34 | 35 | [SerializeField, FormerlySerializedAs("uiEventName")] 36 | private string viewEventName; 37 | 38 | /// 39 | /// Watches a Unity event for updates. 40 | /// 41 | private UnityEventWatcher eventWatcher; 42 | 43 | public override void Connect() 44 | { 45 | string methodName; 46 | object viewModel; 47 | ParseViewModelEndPointReference( 48 | viewModelMethodName, 49 | out methodName, 50 | out viewModel 51 | ); 52 | var viewModelMethod = viewModel.GetType().GetMethod(methodName, new Type[0]); 53 | 54 | string eventName; 55 | Component view; 56 | ParseViewEndPointReference(viewEventName, out eventName, out view); 57 | 58 | eventWatcher = new UnityEventWatcher(view, eventName, 59 | () => viewModelMethod.Invoke(viewModel, new object[0]) 60 | ); 61 | } 62 | 63 | public override void Disconnect() 64 | { 65 | if (eventWatcher != null) 66 | { 67 | eventWatcher.Dispose(); 68 | eventWatcher = null; 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/EventBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f9073289c7daa4449c6f754f7771742 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a996fb2843b0818469069ec9eb55ca35 3 | folderAsset: yes 4 | timeCreated: 1513732860 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/AmbiguousTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Thrown when we are searching for a single type but multiple ones 7 | /// match our query. 8 | /// 9 | public class AmbiguousTypeException : Exception 10 | { 11 | public AmbiguousTypeException(string message) 12 | : base(message) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/AmbiguousTypeException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b1aef062161e9e4cb04c50371510420 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/ComponentNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Exception thrown when the requested component on a GameObject could not be found. 7 | /// 8 | public class ComponentNotFoundException : Exception 9 | { 10 | public ComponentNotFoundException(string message) 11 | : base(message) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/ComponentNotFoundException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26a0a661c7e62b84c91b1487f714fe0f 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidAdapterException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Specified type cannot be used as an adapter for the specified types or does not 7 | /// implement IAdapter. 8 | /// 9 | public class InvalidAdapterException : Exception 10 | { 11 | public InvalidAdapterException(string message) 12 | : base(message) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidAdapterException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49440d3d4a9be7040a60f89f220adada 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidEndPointException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Thrown when an end-point reference was specified in an invalid way and could 7 | /// not be parsed to work out a class or interface name and a member name. 8 | /// 9 | public class InvalidEndPointException : Exception 10 | { 11 | public InvalidEndPointException(string message) 12 | : base(message) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidEndPointException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe1614aea80d2774186d3516f7d01419 3 | timeCreated: 1513732861 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidEventException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Thrown when there is an error binding to a UnityEvent. 7 | /// 8 | public class InvalidEventException : Exception 9 | { 10 | public InvalidEventException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public InvalidEventException(string message, Exception ex) 16 | : base(message, ex) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidEventException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09dac3c27129269408f019d8c2c8be96 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidTypeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// The supplied type is invalid in the current context. 7 | /// 8 | public class InvalidTypeException : Exception 9 | { 10 | public InvalidTypeException(string message) 11 | : base(message) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/InvalidTypeException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b67dd5301f9217b458b820a5f7eabd1c 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/MemberNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Thrown when a property or method could not be found on the specified class or interface. 7 | /// 8 | public class MemberNotFoundException : Exception 9 | { 10 | public MemberNotFoundException(string message) 11 | : base(message) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/MemberNotFoundException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8af3cd2821edcb84db33328a39c02a9f 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/NoSuchAdapterException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// The specified adapter does not exist. 7 | /// 8 | public class NoSuchAdapterException : Exception 9 | { 10 | public NoSuchAdapterException(string adapterTypeName) 11 | : base(string.Format("Could not find adapter type '{0}'.", adapterTypeName)) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/NoSuchAdapterException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e08d360e8a44f7499646e440c534e76 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/PropertyNullException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Thrown when an attempt is made to bind to a property that must not be null. 7 | /// 8 | public class PropertyNullException : Exception 9 | { 10 | public PropertyNullException(string message) 11 | : base (message) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/PropertyNullException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c15ab1d477b952e46918199285827dbd 3 | timeCreated: 1513732861 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/TemplateNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Thrown when the necessary template for a TemplateBinding or CollectionBinding 7 | /// could not be found. 8 | /// 9 | public class TemplateNotFoundException : Exception 10 | { 11 | public TemplateNotFoundException(string message) 12 | : base(message) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/TemplateNotFoundException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80b95411cdf3bd1468f70cbe501693f0 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/ViewModelNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding.Exceptions 4 | { 5 | /// 6 | /// Exception thrown when the requested view-model could not be found. 7 | /// 8 | public class ViewModelNotFoundException : Exception 9 | { 10 | public ViewModelNotFoundException(string message) 11 | : base(message) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Exceptions/ViewModelNotFoundException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b7b75a8aef02bd4e8167d376eaeca11 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/IAdapter.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding 2 | { 3 | /// 4 | /// Base interface for all adapters. Combine with AdapterAttribute to specify 5 | /// the types it supports converting to and from. 6 | /// 7 | public interface IAdapter 8 | { 9 | /// 10 | /// Convert from the source type to the output type. This should throw an exception 11 | /// if the conversion fails or the input isn't valid. 12 | /// 13 | object Convert(object valueIn, AdapterOptions options); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/IAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfeaec6505967714a8d58a04a4b33b53 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/IMemberBinding.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding 2 | { 3 | public interface IMemberBinding 4 | { 5 | void Connect(); 6 | void Disconnect(); 7 | void Init(); 8 | } 9 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/IMemberBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c506908216c4a8242835c0dfd21ae52a 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/INotifyCollectionChanged.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWeld.Binding 4 | { 5 | /// 6 | /// Interface for classes that generate collection changed events. 7 | /// 8 | public interface INotifyCollectionChanged 9 | { 10 | /// 11 | /// Event raised when the collection has been changed. 12 | /// 13 | event EventHandler CollectionChanged; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/INotifyCollectionChanged.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12329316c33d73a43a8ba418df1b87a6 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/ITypedList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UnityWeld.Binding 5 | { 6 | /// 7 | /// A list that exposes the type of its items as a property. 8 | /// 9 | public interface ITypedList : IList 10 | { 11 | /// 12 | /// Specifies the type of items in the list. 13 | /// 14 | Type ItemType { get; } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/ITypedList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb3ad643329bca24aace3b6fb7ec7790 3 | timeCreated: 1513732861 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/IViewModelProvider.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWeld.Binding 2 | { 3 | /// 4 | /// Interface for wiring view-models into the hierarchy. 5 | /// 6 | public interface IViewModelProvider 7 | { 8 | /// 9 | /// Get the view-model provided by this provider. 10 | /// 11 | object GetViewModel(); 12 | 13 | /// 14 | /// Get the name of the view-model's type. 15 | /// 16 | string GetViewModelTypeName(); 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/IViewModelProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9ec305369d991e4794b11220edb37ec 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a22036b69b586a24b869d7252af7c651 3 | folderAsset: yes 4 | timeCreated: 1488238946 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/BindableMember.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace UnityWeld.Binding.Internal 5 | { 6 | /// 7 | /// Data structure combining a bindable property or method with the view model it belongs 8 | /// to. This is needed because we can't always rely on MemberInfo.ReflectedType 9 | /// returning the type of the view model if the property or method was declared in an 10 | /// interface that the view model inherits from. 11 | /// 12 | public class BindableMember where MemberType : MemberInfo 13 | { 14 | /// 15 | /// The bindable member info (usually a PropertyInfo or MethodInfo) 16 | /// 17 | public readonly MemberType Member; 18 | 19 | /// 20 | /// View model that the property or method belongs to. 21 | /// 22 | public readonly Type ViewModelType; 23 | 24 | /// 25 | /// Name of the view model type. 26 | /// 27 | public string ViewModelTypeName 28 | { 29 | get 30 | { 31 | return ViewModelType.Name; 32 | } 33 | } 34 | 35 | /// 36 | /// Name of the member. 37 | /// 38 | public string MemberName 39 | { 40 | get 41 | { 42 | return Member.Name; 43 | } 44 | } 45 | 46 | public BindableMember(MemberType member, Type viewModelType) 47 | { 48 | Member = member; 49 | ViewModelType = viewModelType; 50 | } 51 | 52 | public override string ToString() 53 | { 54 | return string.Concat(ViewModelType.ToString(), ".", MemberName); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/BindableMember.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c314b9c25ad329c4ea179ece81089419 3 | timeCreated: 1513732861 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertyEndPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEngine; 4 | 5 | namespace UnityWeld.Binding.Internal 6 | { 7 | /// 8 | /// Represents an attachment to a property via reflection. 9 | /// 10 | public class PropertyEndPoint 11 | { 12 | /// 13 | /// The object that owns the property. 14 | /// 15 | private readonly object propertyOwner; 16 | 17 | /// 18 | /// The name of the property. 19 | /// 20 | private readonly string propertyName; 21 | 22 | /// 23 | /// Cached reference to the property. 24 | /// 25 | private readonly PropertyInfo property; 26 | 27 | /// 28 | /// Adapter for converting values that are set on the property. 29 | /// 30 | private readonly IAdapter adapter; 31 | 32 | /// 33 | /// Options for using the adapter to convert values. 34 | /// 35 | private readonly AdapterOptions adapterOptions; 36 | 37 | public PropertyEndPoint(object propertyOwner, string propertyName, IAdapter adapter, AdapterOptions options, string endPointType, Component context) 38 | { 39 | this.propertyOwner = propertyOwner; 40 | this.adapter = adapter; 41 | this.adapterOptions = options; 42 | var type = propertyOwner.GetType(); 43 | 44 | if (string.IsNullOrEmpty(propertyName)) 45 | { 46 | Debug.LogError("Property not specified for type '" + type + "'.", context); 47 | return; 48 | } 49 | 50 | this.propertyName = propertyName; 51 | this.property = type.GetProperty(propertyName); 52 | if (this.property == null) 53 | { 54 | Debug.LogError("Property '" + propertyName + "' not found on " + endPointType + " '" + type + "'.", context); 55 | } 56 | } 57 | 58 | /// 59 | /// Get the value of the property. 60 | /// 61 | public object GetValue() 62 | { 63 | return property != null ? property.GetValue(propertyOwner, null) : null; 64 | } 65 | 66 | /// 67 | /// Set the value of the property. 68 | /// 69 | public void SetValue(object input) 70 | { 71 | if (property == null) 72 | { 73 | return; 74 | } 75 | 76 | if (adapter != null) 77 | { 78 | input = adapter.Convert(input, adapterOptions); 79 | } 80 | 81 | property.SetValue(propertyOwner, input, null); 82 | } 83 | 84 | public override string ToString() 85 | { 86 | if (property == null) 87 | { 88 | return "!! property not found !!"; 89 | } 90 | 91 | return string.Concat(propertyOwner.GetType(), ".", property.Name, " (", property.PropertyType.Name, ")"); 92 | } 93 | 94 | /// 95 | /// Watch the property for changes. 96 | /// 97 | public PropertyWatcher Watch(Action changed) 98 | { 99 | return new PropertyWatcher(propertyOwner, propertyName, changed); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertyEndPoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6883c1765b60b6f42afb1fe763febcbd 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertyFinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEngine; 6 | using UnityEngine.Assertions; 7 | 8 | namespace UnityWeld.Binding.Internal 9 | { 10 | /// 11 | /// Helper to find bindable properties. 12 | /// 13 | public static class PropertyFinder 14 | { 15 | /// 16 | /// List of types to exclude from the types of components in the UI we can bind to. 17 | /// 18 | private static readonly HashSet hiddenTypes = new HashSet{ 19 | typeof(AbstractMemberBinding), 20 | typeof(OneWayPropertyBinding), 21 | typeof(TwoWayPropertyBinding) 22 | }; 23 | 24 | /// 25 | /// Use reflection to find all components with properties we can bind to. 26 | /// 27 | public static IEnumerable> GetBindableProperties(GameObject gameObject) //todo: Maybe move this to the TypeResolver. 28 | { 29 | Assert.IsNotNull(gameObject); 30 | 31 | return gameObject.GetComponents() 32 | .Where(component => component != null) 33 | .SelectMany(component => 34 | { 35 | var type = component.GetType(); 36 | return type 37 | .GetProperties(BindingFlags.Instance | BindingFlags.Public) 38 | .Select(p => new BindableMember(p, type)); 39 | }) 40 | .Where(prop => prop.Member.GetSetMethod(false) != null 41 | && prop.Member.GetGetMethod(false) != null 42 | && !hiddenTypes.Contains(prop.ViewModelType) 43 | && !prop.Member.GetCustomAttributes(typeof(ObsoleteAttribute), true).Any() 44 | ); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertyFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ba3a2914142dae469126ba6e4fffa81 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertySync.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityWeld.Binding.Internal 5 | { 6 | /// 7 | /// Syncrhonises the value between two properties using reflection. 8 | /// 9 | public class PropertySync 10 | { 11 | /// 12 | /// The property that is the source of the synchronziation. 13 | /// 14 | private readonly PropertyEndPoint source; 15 | 16 | /// 17 | /// The property that is the destination of the synchronziation. 18 | /// 19 | private readonly PropertyEndPoint dest; 20 | 21 | /// 22 | /// The property that is set for any exception that occurs during type conversion and validation. 23 | /// 24 | private readonly PropertyEndPoint exception; 25 | 26 | /// 27 | /// The Unity context for error logging. 28 | /// 29 | private readonly Component context; 30 | 31 | public PropertySync(PropertyEndPoint source, PropertyEndPoint dest, PropertyEndPoint exception, Component context) 32 | { 33 | this.source = source; 34 | this.dest = dest; 35 | this.exception = exception; 36 | this.context = context; 37 | } 38 | 39 | /// 40 | /// Syncrhonise the value from the source to the destination. 41 | /// 42 | public void SyncFromSource() 43 | { 44 | try 45 | { 46 | dest.SetValue(source.GetValue()); 47 | 48 | if (exception != null) 49 | { 50 | exception.SetValue(null); 51 | } 52 | } 53 | catch (Exception ex) 54 | { 55 | Debug.LogError(string.Format("Failed to convert value from {0} to {1}.", source, dest), context); 56 | Debug.LogException(ex); 57 | } 58 | } 59 | 60 | /// 61 | /// Syncrhonise the value from the destination to the source. 62 | /// 63 | public void SyncFromDest() 64 | { 65 | try 66 | { 67 | source.SetValue(dest.GetValue()); 68 | 69 | if (exception != null) 70 | { 71 | exception.SetValue(null); 72 | } 73 | } 74 | catch (Exception ex) 75 | { 76 | if (exception != null) 77 | { 78 | exception.SetValue(ex); 79 | } 80 | else 81 | { 82 | Debug.LogError(string.Format("Failed to convert value from {0} to {1}.", source, dest), context); 83 | Debug.LogException(ex); 84 | } 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertySync.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3a5f4f5c7c0e0440b73563c1c3342bd 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertyWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace UnityWeld.Binding.Internal 5 | { 6 | /// 7 | /// Watches an object for property changes and invokes an action when the property has changed. 8 | /// 9 | public class PropertyWatcher : IDisposable 10 | { 11 | /// 12 | /// The object that owns the property that is being watched. 13 | /// 14 | private object propertyOwner; 15 | 16 | /// 17 | /// The name of the property that is being watched. 18 | /// 19 | private readonly string propertyName; 20 | 21 | /// 22 | /// The action to invoke when the property has changed. 23 | /// 24 | private readonly Action action; 25 | 26 | private bool disposed; 27 | 28 | public PropertyWatcher(object propertyOwner, string propertyName, Action action) 29 | { 30 | this.propertyOwner = propertyOwner; 31 | this.propertyName = propertyName; 32 | this.action = action; 33 | 34 | var notifyPropertyChanged = propertyOwner as INotifyPropertyChanged; 35 | if (notifyPropertyChanged != null) 36 | { 37 | notifyPropertyChanged.PropertyChanged += propertyOwner_PropertyChanged; 38 | } 39 | } 40 | 41 | public void Dispose() 42 | { 43 | Dispose(true); 44 | GC.SuppressFinalize(this); 45 | } 46 | 47 | protected virtual void Dispose(bool disposing) 48 | { 49 | if (disposed) 50 | { 51 | return; 52 | } 53 | 54 | if (disposing && propertyOwner != null) 55 | { 56 | var notifyPropertyChanged = propertyOwner as INotifyPropertyChanged; 57 | if (notifyPropertyChanged != null) 58 | { 59 | notifyPropertyChanged.PropertyChanged -= propertyOwner_PropertyChanged; 60 | } 61 | 62 | propertyOwner = null; 63 | } 64 | 65 | disposed = true; 66 | } 67 | 68 | private void propertyOwner_PropertyChanged(object sender, PropertyChangedEventArgs e) 69 | { 70 | if (e.PropertyName == propertyName) 71 | { 72 | action(); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/PropertyWatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 844c8c92ca5fe1a4a8a04411c45f92a1 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/TypeResolver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c12bdb239d396014ea5c143377bde1a2 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/UnityEventBinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEngine.Events; 4 | using UnityWeld.Binding.Exceptions; 5 | 6 | namespace UnityWeld.Binding.Internal 7 | { 8 | /// 9 | /// Factory for adding the correct type of listener to a generic UnityEvent, given a view model and 10 | /// the name of a method in that view model to bind the UnityEvent to. 11 | /// 12 | internal static class UnityEventBinderFactory 13 | { 14 | /// 15 | /// Set up and bind a given UnityEvent with a list of types matching its generic type arguments. 16 | /// 17 | public static UnityEventBinderBase Create(UnityEventBase unityEvent, Action action) 18 | { 19 | // Note that to find the paramaters of events on the UI, we need to see what 20 | // generic arguments were passed to the UnityEvent they inherit from. 21 | var eventArgumentTypes = unityEvent.GetType().BaseType.GetGenericArguments(); 22 | 23 | if (!eventArgumentTypes.Any()) 24 | { 25 | return new UnityEventBinder(unityEvent, action); 26 | } 27 | 28 | try 29 | { 30 | var genericType = typeof(UnityEventBinder<>).MakeGenericType(eventArgumentTypes); 31 | return (UnityEventBinderBase)Activator.CreateInstance(genericType, unityEvent, action); 32 | } 33 | catch (ArgumentException ex) 34 | { 35 | // There are only UnityEvents and UnityActions that support up to 5 arguments. 36 | // MakeGenericType will throw an ArgumentException if it is used to try and create a type with arguments that don't match any generic type. 37 | throw new InvalidEventException("Cannot bind event with more than 5 arguments", ex); 38 | } 39 | 40 | } 41 | } 42 | 43 | /// 44 | /// Abstract class for generic event binders to inherit from. 45 | /// 46 | internal abstract class UnityEventBinderBase : IDisposable 47 | { 48 | public abstract void Dispose(); 49 | } 50 | 51 | internal class UnityEventBinder : UnityEventBinderBase 52 | { 53 | private UnityEvent unityEvent; 54 | private readonly Action action; 55 | 56 | public UnityEventBinder(UnityEventBase unityEvent, Action action) 57 | { 58 | this.unityEvent = (UnityEvent)unityEvent; 59 | this.action = action; 60 | this.unityEvent.AddListener(EventHandler); 61 | } 62 | 63 | public override void Dispose() 64 | { 65 | if (unityEvent == null) 66 | { 67 | return; 68 | } 69 | 70 | unityEvent.RemoveListener(EventHandler); 71 | unityEvent = null; 72 | } 73 | 74 | private void EventHandler() 75 | { 76 | action(); 77 | } 78 | } 79 | 80 | internal class UnityEventBinder : UnityEventBinderBase 81 | { 82 | private UnityEvent unityEvent; 83 | private readonly Action action; 84 | 85 | public UnityEventBinder(UnityEventBase unityEvent, Action action) 86 | { 87 | this.unityEvent = (UnityEvent)unityEvent; 88 | this.action = action; 89 | this.unityEvent.AddListener(EventHandler); 90 | } 91 | 92 | public override void Dispose() 93 | { 94 | if (unityEvent == null) 95 | { 96 | return; 97 | } 98 | 99 | unityEvent.RemoveListener(EventHandler); 100 | unityEvent = null; 101 | } 102 | 103 | private void EventHandler(T0 arg0) 104 | { 105 | action(); 106 | } 107 | } 108 | 109 | internal class UnityEventBinder : UnityEventBinderBase 110 | { 111 | private UnityEvent unityEvent; 112 | private readonly Action action; 113 | 114 | public UnityEventBinder(UnityEventBase unityEvent, Action action) 115 | { 116 | this.unityEvent = (UnityEvent)unityEvent; 117 | this.action = action; 118 | this.unityEvent.AddListener(EventHandler); 119 | } 120 | 121 | public override void Dispose() 122 | { 123 | if (unityEvent == null) 124 | { 125 | return; 126 | } 127 | 128 | unityEvent.RemoveListener(EventHandler); 129 | unityEvent = null; 130 | } 131 | 132 | private void EventHandler(T0 arg0, T1 arg1) 133 | { 134 | action(); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/UnityEventBinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0fe8837b28c49048a118e13b997beb0 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/UnityEventWatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEngine; 6 | using UnityEngine.Assertions; 7 | using UnityEngine.Events; 8 | using UnityWeld.Binding.Exceptions; 9 | 10 | namespace UnityWeld.Binding.Internal 11 | { 12 | /// 13 | /// Information needed to bind to a UnityEvent on a component. 14 | /// 15 | public class BindableEvent 16 | { 17 | /// 18 | /// UnityEvent to bind to. 19 | /// 20 | public UnityEventBase UnityEvent { get; set; } 21 | 22 | /// 23 | /// The name of the property or field contaning this event. 24 | /// 25 | public string Name { get; set; } 26 | 27 | /// 28 | /// The type that the event belongs to. 29 | /// 30 | public Type DeclaringType { get; set; } 31 | 32 | /// 33 | /// Type of the component we're binding to. This doesn't account for multiple 34 | /// components of the same type on the same GameObject, but there doesn't seem 35 | /// to be any other easy way of doing that since component instance IDs are 36 | /// re-generated frequently. 37 | /// 38 | public Type ComponentType { get; set; } 39 | } 40 | 41 | /// 42 | /// Watches an component for a Unity event and triggers an action when the event is raised. 43 | /// 44 | public class UnityEventWatcher : IDisposable 45 | { 46 | /// 47 | /// Helper object that links to the Unity event. 48 | /// 49 | private UnityEventBinderBase unityEventBinder; 50 | 51 | private bool disposed; 52 | 53 | public UnityEventWatcher(Component component, string eventName, Action action) 54 | { 55 | Assert.IsNotNull(component); 56 | Assert.IsFalse(string.IsNullOrEmpty(eventName)); 57 | Assert.IsNotNull(action); 58 | 59 | unityEventBinder = UnityEventBinderFactory.Create(GetBoundEvent(eventName, component).UnityEvent, action); 60 | } 61 | 62 | public void Dispose() 63 | { 64 | Dispose(true); 65 | GC.SuppressFinalize(this); 66 | } 67 | 68 | protected virtual void Dispose(bool disposing) 69 | { 70 | if (disposed) 71 | { 72 | return; 73 | } 74 | 75 | if (disposing && unityEventBinder != null) 76 | { 77 | unityEventBinder.Dispose(); 78 | unityEventBinder = null; 79 | } 80 | 81 | disposed = true; 82 | } 83 | 84 | 85 | /// 86 | /// Get all bindable Unity events from a particular component. 87 | /// 88 | private static IEnumerable GetBindableEvents(Component component) 89 | { 90 | Assert.IsNotNull(component, "Cannot get bindinable events of a null component."); 91 | 92 | var type = component.GetType(); 93 | 94 | var bindableEventsFromProperties = type 95 | .GetProperties(BindingFlags.Instance | BindingFlags.Public) 96 | .Where(propertyInfo => propertyInfo.PropertyType.IsSubclassOf(typeof(UnityEventBase))) 97 | .Where(propertyInfo => !propertyInfo.GetCustomAttributes(typeof(ObsoleteAttribute), true).Any()) 98 | .Select(propertyInfo => new BindableEvent() 99 | { 100 | UnityEvent = (UnityEventBase)propertyInfo.GetValue(component, null), 101 | Name = propertyInfo.Name, 102 | DeclaringType = propertyInfo.DeclaringType, 103 | ComponentType = component.GetType() 104 | }); 105 | 106 | var bindableEventsFromFields = type 107 | .GetFields(BindingFlags.Instance | BindingFlags.Public) 108 | .Where(fieldInfo => fieldInfo.FieldType.IsSubclassOf(typeof(UnityEventBase))) 109 | .Where(fieldInfo => !fieldInfo.GetCustomAttributes(typeof(ObsoleteAttribute), true).Any()) 110 | .Select(fieldInfo => new BindableEvent 111 | { 112 | UnityEvent = (UnityEventBase)fieldInfo.GetValue(component), 113 | Name = fieldInfo.Name, 114 | DeclaringType = fieldInfo.DeclaringType, 115 | ComponentType = type 116 | }); 117 | 118 | return bindableEventsFromFields.Concat(bindableEventsFromProperties); 119 | } 120 | 121 | /// 122 | /// Get a particular Unity event from a component. 123 | /// 124 | private static BindableEvent GetBoundEvent(string boundEventName, Component component) 125 | { 126 | Assert.IsNotNull(component); 127 | Assert.IsFalse(string.IsNullOrEmpty(boundEventName)); 128 | 129 | var componentType = component.GetType(); 130 | var boundEvent = GetBindableEvents(component) 131 | .FirstOrDefault(); 132 | 133 | if (boundEvent == null) 134 | { 135 | throw new InvalidEventException(string.Format("Could not bind to event \"{0}\" on component \"{1}\".", boundEventName, componentType)); 136 | } 137 | 138 | return boundEvent; 139 | } 140 | 141 | /// 142 | /// Get all bindable Unity events on a particular game object. 143 | /// 144 | public static BindableEvent[] GetBindableEvents(GameObject gameObject) //todo: Consider moving this to TypeResolver. 145 | { 146 | Assert.IsNotNull(gameObject); 147 | 148 | return gameObject.GetComponents(typeof(Component)) 149 | .Where(component => component != null) 150 | .SelectMany(GetBindableEvents) 151 | .ToArray(); 152 | } 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Internal/UnityEventWatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6f45d956fab92e4697a0b4ca477add0 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/NotifyCollectionChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace UnityWeld.Binding 5 | { 6 | public enum NotifyCollectionChangedAction 7 | { 8 | Add, 9 | Remove, 10 | Reset, 11 | } 12 | 13 | /// 14 | /// Arguments for collection changed event. 15 | /// 16 | public class NotifyCollectionChangedEventArgs : EventArgs 17 | { 18 | /// 19 | /// Gets the action that caused the event. 20 | /// 21 | /// Returns: 22 | /// A System.Collections.Specialized.NotifyCollectionChangedAction value that 23 | /// describes the action that caused the event. 24 | /// 25 | public NotifyCollectionChangedAction Action { get; private set; } 26 | 27 | /// 28 | /// Gets the list of new items involved in the change. 29 | /// 30 | /// Returns: 31 | /// The list of new items involved in the change. 32 | /// 33 | public IList NewItems { get; private set; } 34 | 35 | /// 36 | /// Gets the index at which the change occurred. 37 | /// 38 | /// Returns: 39 | /// The zero-based index at which the change occurred. 40 | /// 41 | public int NewStartingIndex { get; private set; } 42 | 43 | /// 44 | /// Gets the list of items affected by a System.Collections.Specialized.NotifyCollectionChangedAction.Replace, 45 | /// Remove, or Move action. 46 | /// 47 | /// Returns: 48 | /// The list of items affected by a System.Collections.Specialized.NotifyCollectionChangedAction.Replace, 49 | /// Remove, or Move action. 50 | /// 51 | public IList OldItems { get; private set; } 52 | 53 | /// 54 | /// Gets the index at which a System.Collections.Specialized.NotifyCollectionChangedAction.Move, 55 | /// Remove, or Replace action occurred. 56 | /// 57 | /// Returns: 58 | /// The zero-based index at which a System.Collections.Specialized.NotifyCollectionChangedAction.Move, 59 | /// Remove, or Replace action occurred. 60 | /// 61 | public int OldStartingIndex { get; private set; } 62 | 63 | public static NotifyCollectionChangedEventArgs ItemAdded(object item, int index) 64 | { 65 | return new NotifyCollectionChangedEventArgs() 66 | { 67 | Action = NotifyCollectionChangedAction.Add, 68 | NewItems = new[] { item }, 69 | NewStartingIndex = index, 70 | }; 71 | } 72 | 73 | public static NotifyCollectionChangedEventArgs ItemRemoved(object item, int index) 74 | { 75 | return new NotifyCollectionChangedEventArgs() 76 | { 77 | Action = NotifyCollectionChangedAction.Remove, 78 | OldItems = new[] { item }, 79 | OldStartingIndex = index, 80 | }; 81 | } 82 | 83 | public static NotifyCollectionChangedEventArgs Reset(object[] items) 84 | { 85 | return new NotifyCollectionChangedEventArgs() 86 | { 87 | Action = NotifyCollectionChangedAction.Reset, 88 | OldItems = items, 89 | OldStartingIndex = 0, 90 | }; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/NotifyCollectionChangedEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cda505731b2eb24ca4c3a25aae24a7a 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/ObservableList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f11f1c043d3de62418653051bb0e0626 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/OneWayPropertyBinding.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Serialization; 3 | using UnityWeld.Binding.Internal; 4 | 5 | namespace UnityWeld.Binding 6 | { 7 | /// 8 | /// Bind a property in the view model to one on the UI, subscribing to OnPropertyChanged 9 | /// and updating the UI accordingly (note that this does not update the view model when 10 | /// the UI changes). 11 | /// 12 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 13 | public class OneWayPropertyBinding : AbstractMemberBinding 14 | { 15 | /// 16 | /// Type of the adapter we're using to adapt between the view model property 17 | /// and UI property. 18 | /// 19 | public string ViewAdapterTypeName 20 | { 21 | get { return viewAdapterTypeName; } 22 | set { viewAdapterTypeName = value; } 23 | } 24 | 25 | [SerializeField] 26 | private string viewAdapterTypeName; 27 | 28 | /// 29 | /// Options for adapting from the view model to the UI property. 30 | /// 31 | public AdapterOptions ViewAdapterOptions 32 | { 33 | get { return viewAdapterOptions; } 34 | set { viewAdapterOptions = value; } 35 | } 36 | 37 | [SerializeField] 38 | private AdapterOptions viewAdapterOptions; 39 | 40 | /// 41 | /// Name of the property in the view model to bind. 42 | /// 43 | public string ViewModelPropertyName 44 | { 45 | get { return viewModelPropertyName; } 46 | set { viewModelPropertyName = value; } 47 | } 48 | 49 | [SerializeField] 50 | private string viewModelPropertyName; 51 | 52 | /// 53 | /// Property on the view to update when value changes. 54 | /// 55 | public string ViewPropertyName 56 | { 57 | get { return viewPropertyName; } 58 | set { viewPropertyName = value; } 59 | } 60 | 61 | [SerializeField, FormerlySerializedAs("uiPropertyName")] 62 | private string viewPropertyName; 63 | 64 | /// 65 | /// Watches the view-model for changes that must be propagated to the view. 66 | /// 67 | private PropertyWatcher viewModelWatcher; 68 | 69 | public override void Connect() 70 | { 71 | string propertyName; 72 | Component view; 73 | ParseViewEndPointReference(viewPropertyName, out propertyName, out view); 74 | 75 | var viewModelEndPoint = MakeViewModelEndPoint(viewModelPropertyName, null, null); 76 | 77 | var propertySync = new PropertySync( 78 | // Source 79 | viewModelEndPoint, 80 | 81 | // Dest 82 | new PropertyEndPoint( 83 | view, 84 | propertyName, 85 | CreateAdapter(viewAdapterTypeName), 86 | viewAdapterOptions, 87 | "view", 88 | this 89 | ), 90 | 91 | // Errors, exceptions and validation. 92 | null, // Validation not needed 93 | 94 | this 95 | ); 96 | 97 | viewModelWatcher = viewModelEndPoint.Watch( 98 | () => propertySync.SyncFromSource() 99 | ); 100 | 101 | // Copy the initial value over from the view-model. 102 | propertySync.SyncFromSource(); 103 | } 104 | 105 | public override void Disconnect() 106 | { 107 | if (viewModelWatcher != null) 108 | { 109 | viewModelWatcher.Dispose(); 110 | viewModelWatcher = null; 111 | } 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/OneWayPropertyBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26fff9f3256f02d43b6065b078449891 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/SubViewModelBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityWeld.Binding.Exceptions; 4 | using UnityWeld.Binding.Internal; 5 | 6 | namespace UnityWeld.Binding 7 | { 8 | /// 9 | /// Bind a sub-view model which is a property on another view model for use in the UI. 10 | /// 11 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 12 | public class SubViewModelBinding : AbstractMemberBinding, IViewModelProvider 13 | { 14 | /// 15 | /// Get the view-model provided by this provider. 16 | /// 17 | public object GetViewModel() 18 | { 19 | if (viewModel == null) 20 | { 21 | Connect(); 22 | } 23 | 24 | return viewModel; 25 | } 26 | 27 | /// 28 | /// Get the name of the view-model's type. 29 | /// 30 | public string GetViewModelTypeName() 31 | { 32 | return viewModelTypeName; 33 | } 34 | 35 | /// 36 | /// Name of the property in the view-model that contains the sub-viewmodel. 37 | /// 38 | public string ViewModelPropertyName 39 | { 40 | get { return viewModelPropertyName; } 41 | set { viewModelPropertyName = value; } 42 | } 43 | 44 | [SerializeField] 45 | private string viewModelPropertyName; 46 | 47 | /// 48 | /// Name of the type of the view model we're binding to. Set from the Unity inspector. 49 | /// 50 | public string ViewModelTypeName 51 | { 52 | get { return viewModelTypeName; } 53 | set { viewModelTypeName = value; } 54 | } 55 | 56 | [SerializeField] 57 | private string viewModelTypeName; 58 | 59 | /// 60 | /// Watches the view-model proper for changes. 61 | /// 62 | private PropertyWatcher viewModelPropertyWatcher; 63 | 64 | /// 65 | /// Cached view-model object. 66 | /// 67 | private object viewModel; 68 | 69 | /// 70 | /// Initialise the bound view model by getting the property from the parent view model. 71 | /// 72 | private void UpdateViewModel() 73 | { 74 | string propertyName; 75 | object parentViewModel; 76 | ParseViewModelEndPointReference(viewModelPropertyName, out propertyName, out parentViewModel); 77 | 78 | var propertyInfo = parentViewModel.GetType().GetProperty(propertyName); 79 | if (propertyInfo == null) 80 | { 81 | throw new MemberNotFoundException(string.Format("Could not find property \"{0}\" on view model \"{1}\".", propertyName, parentViewModel.GetType())); 82 | } 83 | 84 | viewModel = propertyInfo.GetValue(parentViewModel, null); 85 | } 86 | 87 | public override void Connect() 88 | { 89 | if (viewModelPropertyWatcher != null) 90 | { 91 | // Already connected - no need to connect again. 92 | return; 93 | } 94 | 95 | string propertyName; 96 | object parentViewModel; 97 | ParseViewModelEndPointReference(viewModelPropertyName, out propertyName, out parentViewModel); 98 | 99 | viewModelPropertyWatcher = new PropertyWatcher(parentViewModel, propertyName, NotifyPropertyChanged_PropertyChanged); 100 | 101 | UpdateViewModel(); 102 | } 103 | 104 | public override void Disconnect() 105 | { 106 | if (viewModelPropertyWatcher != null) 107 | { 108 | viewModelPropertyWatcher.Dispose(); 109 | viewModelPropertyWatcher = null; 110 | } 111 | } 112 | 113 | private void NotifyPropertyChanged_PropertyChanged() 114 | { 115 | UpdateViewModel(); 116 | 117 | // Rebind all children. 118 | foreach (var memberBinding in GetComponentsInChildren()) 119 | { 120 | if (memberBinding == this) 121 | { 122 | continue; 123 | } 124 | 125 | memberBinding.Init(); 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/SubViewModelBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49626dc5a75e18d47b9eedb772ba5906 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Template.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Assertions; 3 | 4 | namespace UnityWeld.Binding 5 | { 6 | /// 7 | /// Template for use in collection bindings. 8 | /// 9 | public interface ITemplate 10 | { 11 | /// 12 | /// Set the view model and initialise all binding objects down the hierarchy. 13 | /// 14 | void InitChildBindings(object viewModel); 15 | } 16 | 17 | /// 18 | /// Template for use in collection bindings. 19 | /// 20 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 21 | public class Template : MonoBehaviour, IViewModelProvider, ITemplate 22 | { 23 | /// 24 | /// Get the view-model provided by this provider. 25 | /// 26 | public object GetViewModel() 27 | { 28 | return viewModel; 29 | } 30 | 31 | /// 32 | /// Get the name of the view-model's type. 33 | /// 34 | public string GetViewModelTypeName() 35 | { 36 | return viewModelTypeName; 37 | } 38 | 39 | public string ViewModelTypeName 40 | { 41 | get { return viewModelTypeName; } 42 | set { viewModelTypeName = value; } 43 | } 44 | 45 | [SerializeField] 46 | private string viewModelTypeName = string.Empty; 47 | 48 | /// 49 | /// Cached view-model object. 50 | /// 51 | private object viewModel; 52 | 53 | /// 54 | /// Set the view model and initialise all binding objects down the hierarchy. 55 | /// 56 | public void InitChildBindings(object viewModel) 57 | { 58 | Assert.IsNotNull(viewModel, "Cannot initialise child bindings with null view model."); 59 | 60 | // Set the bound view to the new view model. 61 | this.viewModel = viewModel; 62 | 63 | foreach (var binding in GetComponentsInChildren()) 64 | { 65 | binding.Init(); 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/Template.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14fbe316db38e1b48a273eac0c26fe31 3 | timeCreated: 1489473064 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/TemplateBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEngine; 4 | using UnityWeld.Binding.Exceptions; 5 | using UnityWeld.Binding.Internal; 6 | 7 | namespace UnityWeld.Binding 8 | { 9 | /// 10 | /// Binds to a view and instantiates a template based on the view type. 11 | /// 12 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 13 | public class TemplateBinding : AbstractTemplateSelector 14 | { 15 | /// 16 | /// The property of the view model that is being bound to 17 | /// 18 | private PropertyInfo viewModelProperty; 19 | 20 | /// 21 | /// Connect to the attached view model. 22 | /// 23 | public override void Connect() 24 | { 25 | Disconnect(); 26 | 27 | string propertyName; 28 | ParseViewModelEndPointReference( 29 | ViewModelPropertyName, 30 | out propertyName, 31 | out viewModel 32 | ); 33 | 34 | viewModelPropertyWatcher = new PropertyWatcher( 35 | viewModel, 36 | propertyName, 37 | InitalizeTemplate 38 | ); 39 | 40 | // Get property from view model. 41 | viewModelProperty = viewModel.GetType().GetProperty(propertyName); 42 | if (viewModelProperty == null) 43 | { 44 | throw new MemberNotFoundException(string.Format( 45 | "Expected property {0} on type {1}, but was not found.", 46 | propertyName, 47 | viewModel.GetType().Name 48 | )); 49 | } 50 | 51 | InitalizeTemplate(); 52 | } 53 | 54 | 55 | /// 56 | /// Disconnect from the attached view model. 57 | /// 58 | public override void Disconnect() 59 | { 60 | DestroyAllTemplates(); 61 | 62 | if (viewModelPropertyWatcher != null) 63 | { 64 | viewModelPropertyWatcher.Dispose(); 65 | viewModelPropertyWatcher = null; 66 | } 67 | 68 | viewModel = null; 69 | } 70 | 71 | /// 72 | /// Initalized the correct tempalte based on the type. 73 | /// 74 | private void InitalizeTemplate() 75 | { 76 | DestroyAllTemplates(); 77 | 78 | // Get value from view model. 79 | var viewModelPropertyValue = viewModelProperty.GetValue(viewModel, null); 80 | if (viewModelPropertyValue == null) 81 | { 82 | throw new PropertyNullException(string.Format( 83 | "TemplateBinding cannot bind to null property in view: {0}.", 84 | ViewModelPropertyName 85 | )); 86 | } 87 | 88 | InstantiateTemplate(viewModelPropertyValue); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/TemplateBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ddad2d4c908040c49924228ac5498061 3 | timeCreated: 1488238950 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/ToggleActiveBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEngine; 4 | using UnityEngine.Assertions; 5 | using UnityWeld.Binding.Internal; 6 | 7 | namespace UnityWeld.Binding 8 | { 9 | /// 10 | /// Bind to a boolean property on the view model and turn all child objects on 11 | /// or off based on its value. 12 | /// 13 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 14 | public class ToggleActiveBinding : AbstractMemberBinding 15 | { 16 | /// 17 | /// Type of the adapter we're using to adapt between the view model property 18 | /// and view property. 19 | /// 20 | public string ViewAdapterTypeName 21 | { 22 | get { return viewAdapterTypeName; } 23 | set { viewAdapterTypeName = value; } 24 | } 25 | 26 | [SerializeField] 27 | private string viewAdapterTypeName; 28 | 29 | /// 30 | /// Options for adapting from the view model to the view property. 31 | /// 32 | public AdapterOptions ViewAdapterOptions 33 | { 34 | get { return viewAdapterOptions; } 35 | set { viewAdapterOptions = value; } 36 | } 37 | 38 | [SerializeField] 39 | private AdapterOptions viewAdapterOptions; 40 | 41 | /// 42 | /// Name of the property in the view model to bind. 43 | /// 44 | public string ViewModelPropertyName 45 | { 46 | get { return viewModelPropertyName; } 47 | set { viewModelPropertyName = value; } 48 | } 49 | 50 | [SerializeField] 51 | private string viewModelPropertyName; 52 | 53 | /// 54 | /// Watcher the view-model for changes that must be propagated to the view. 55 | /// 56 | private PropertyWatcher viewModelWatcher; 57 | 58 | /// 59 | /// Preoprty for the propertySync to set in order to activate and deactivate all children 60 | /// 61 | public bool ChildrenActive 62 | { 63 | set 64 | { 65 | SetAllChildrenActive(value); 66 | } 67 | } 68 | 69 | 70 | public override void Connect() 71 | { 72 | var viewModelEndPoint = MakeViewModelEndPoint(viewModelPropertyName, null, null); 73 | 74 | var propertySync = new PropertySync( 75 | // Source 76 | viewModelEndPoint, 77 | 78 | // Dest 79 | new PropertyEndPoint( 80 | this, 81 | "ChildrenActive", 82 | CreateAdapter(viewAdapterTypeName), 83 | viewAdapterOptions, 84 | "view", 85 | this 86 | ), 87 | 88 | // Errors, exceptions and validation. 89 | null, // Validation not needed 90 | 91 | this 92 | ); 93 | 94 | viewModelWatcher = viewModelEndPoint.Watch( 95 | () => propertySync.SyncFromSource() 96 | ); 97 | 98 | // Copy the initial value over from the view-model. 99 | propertySync.SyncFromSource(); 100 | } 101 | 102 | public override void Disconnect() 103 | { 104 | if (viewModelWatcher != null) 105 | { 106 | viewModelWatcher.Dispose(); 107 | viewModelWatcher = null; 108 | } 109 | } 110 | 111 | private void SetAllChildrenActive(bool active) 112 | { 113 | foreach (Transform child in transform) 114 | { 115 | child.gameObject.SetActive(active); 116 | } 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/ToggleActiveBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b68e6480f6f9d3e418da029db7ef8496 3 | timeCreated: 1513732860 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Binding/TwoWayPropertyBinding.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26990677ffff9664d853a81fcb765384 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Widgets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bb45967e8a76f7459634500a2240ea4 3 | folderAsset: yes 4 | timeCreated: 1488238946 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Widgets/DropdownAdapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.UI; 6 | using UnityWeld.Binding.Exceptions; 7 | 8 | namespace UnityWeld.Widgets 9 | { 10 | /// 11 | /// Adapter to set up and bind to a Dropdown using strings instead of OptionData. 12 | /// 13 | [HelpURL("https://github.com/Real-Serious-Games/Unity-Weld")] 14 | public class DropdownAdapter : MonoBehaviour 15 | { 16 | private Dropdown dropdown; 17 | private Dropdown Dropdown 18 | { 19 | get 20 | { 21 | if (dropdown == null) 22 | { 23 | dropdown = GetComponent(); 24 | if (dropdown == null) 25 | { 26 | throw new ComponentNotFoundException("DropdownAdapter must be placed on an object with a Dropdown"); 27 | } 28 | 29 | // Dropdown should start with empty list of options 30 | dropdown.options.Clear(); 31 | 32 | // Bind event for dropdown value changed 33 | dropdown.onValueChanged.AddListener(newItemIndex => 34 | OnValueChanged.Invoke(dropdown.options[newItemIndex].text)); 35 | } 36 | return dropdown; 37 | } 38 | } 39 | 40 | [Serializable] 41 | public class DropdownStringEvent : UnityEvent { } 42 | 43 | [SerializeField] 44 | private DropdownStringEvent onValueChanged = new DropdownStringEvent(); 45 | public DropdownStringEvent OnValueChanged 46 | { 47 | get 48 | { 49 | return onValueChanged; 50 | } 51 | set 52 | { 53 | onValueChanged = value; 54 | } 55 | } 56 | 57 | /// 58 | /// Used to remember the selection if it gets set before the options list is set. 59 | /// 60 | private string cachedSelection; 61 | 62 | /// 63 | /// String of all the text options in the dropdown. 64 | /// 65 | public string[] Options 66 | { 67 | get 68 | { 69 | return Dropdown.options 70 | .Select(option => option.text) 71 | .ToArray(); 72 | } 73 | set 74 | { 75 | Dropdown.options = value 76 | .Select(optionString => new Dropdown.OptionData(optionString)) 77 | .ToList(); 78 | 79 | // Initialise the selection if it was already set before the options list was populated. 80 | if (cachedSelection != String.Empty) 81 | { 82 | SetSelection(cachedSelection); 83 | } 84 | } 85 | } 86 | 87 | /// 88 | /// String of the text of the currently selected option. 89 | /// 90 | public string SelectedOption 91 | { 92 | get 93 | { 94 | if (Dropdown.options.Count > 0) 95 | { 96 | return Dropdown.options[Dropdown.value].text; 97 | } 98 | else 99 | { 100 | return String.Empty; 101 | } 102 | } 103 | set 104 | { 105 | SetSelection(value); 106 | } 107 | } 108 | 109 | /// 110 | /// If the options list has been initialised, set the selection and clear any cached selection. 111 | /// Otherwise store it for use later since the list of options must be initialised before we can select one. 112 | /// 113 | private void SetSelection(string value) 114 | { 115 | // If the options list hasn't been initialised yet, store the value for later. 116 | if (Dropdown.options.Count == 0) 117 | { 118 | cachedSelection = value; 119 | } 120 | else 121 | { 122 | Dropdown.value = Dropdown.options 123 | .Select(option => option.text) 124 | .ToList() 125 | .IndexOf(value); 126 | cachedSelection = String.Empty; 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Assets/Unity-Weld/UnityWeld/Widgets/DropdownAdapter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6185afe199ebab4cbd383cbb730bb02 3 | timeCreated: 1488238949 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Real Serious Games 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 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_SolverIterationCount: 6 13 | m_QueriesHitTriggers: 1 14 | m_EnableAdaptiveForce: 0 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 2 13 | m_SpritePackerPaddingPower: 1 14 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 15 | m_ProjectGenerationRootNamespace: 16 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_TierSettings_Tier1: 42 | renderingPath: 1 43 | useCascadedShadowMaps: 1 44 | m_TierSettings_Tier2: 45 | renderingPath: 1 46 | useCascadedShadowMaps: 1 47 | m_TierSettings_Tier3: 48 | renderingPath: 1 49 | useCascadedShadowMaps: 1 50 | m_DefaultRenderingPath: 1 51 | m_DefaultMobileRenderingPath: 1 52 | m_TierSettings: [] 53 | m_LightmapStripping: 0 54 | m_FogStripping: 0 55 | m_LightmapKeepPlain: 1 56 | m_LightmapKeepDirCombined: 1 57 | m_LightmapKeepDirSeparate: 1 58 | m_LightmapKeepDynamicPlain: 1 59 | m_LightmapKeepDynamicDirCombined: 1 60 | m_LightmapKeepDynamicDirSeparate: 1 61 | m_FogKeepLinear: 1 62 | m_FogKeepExp: 1 63 | m_FogKeepExp2: 1 64 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_MinPenetrationForPenalty: 0.01 17 | m_BaumgarteScale: 0.2 18 | m_BaumgarteTimeOfImpactScale: 0.75 19 | m_TimeToSleep: 0.5 20 | m_LinearSleepTolerance: 0.01 21 | m_AngularSleepTolerance: 2 22 | m_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 26 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.2.1f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 2 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | blendWeights: 1 21 | textureQuality: 1 22 | anisotropicTextures: 0 23 | antiAliasing: 0 24 | softParticles: 0 25 | softVegetation: 0 26 | realtimeReflectionProbes: 0 27 | billboardsFaceCameraPosition: 0 28 | vSyncCount: 0 29 | lodBias: 0.3 30 | maximumLODLevel: 0 31 | particleRaycastBudget: 4 32 | asyncUploadTimeSlice: 2 33 | asyncUploadBufferSize: 4 34 | excludedTargetPlatforms: [] 35 | - serializedVersion: 2 36 | name: Fast 37 | pixelLightCount: 0 38 | shadows: 0 39 | shadowResolution: 0 40 | shadowProjection: 1 41 | shadowCascades: 1 42 | shadowDistance: 20 43 | shadowNearPlaneOffset: 2 44 | shadowCascade2Split: 0.33333334 45 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 46 | blendWeights: 2 47 | textureQuality: 0 48 | anisotropicTextures: 0 49 | antiAliasing: 0 50 | softParticles: 0 51 | softVegetation: 0 52 | realtimeReflectionProbes: 0 53 | billboardsFaceCameraPosition: 0 54 | vSyncCount: 0 55 | lodBias: 0.4 56 | maximumLODLevel: 0 57 | particleRaycastBudget: 16 58 | asyncUploadTimeSlice: 2 59 | asyncUploadBufferSize: 4 60 | excludedTargetPlatforms: [] 61 | - serializedVersion: 2 62 | name: Simple 63 | pixelLightCount: 1 64 | shadows: 1 65 | shadowResolution: 0 66 | shadowProjection: 1 67 | shadowCascades: 1 68 | shadowDistance: 20 69 | shadowNearPlaneOffset: 2 70 | shadowCascade2Split: 0.33333334 71 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 72 | blendWeights: 2 73 | textureQuality: 0 74 | anisotropicTextures: 1 75 | antiAliasing: 0 76 | softParticles: 0 77 | softVegetation: 0 78 | realtimeReflectionProbes: 0 79 | billboardsFaceCameraPosition: 0 80 | vSyncCount: 0 81 | lodBias: 0.7 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 64 84 | asyncUploadTimeSlice: 2 85 | asyncUploadBufferSize: 4 86 | excludedTargetPlatforms: [] 87 | - serializedVersion: 2 88 | name: Good 89 | pixelLightCount: 2 90 | shadows: 2 91 | shadowResolution: 1 92 | shadowProjection: 1 93 | shadowCascades: 2 94 | shadowDistance: 40 95 | shadowNearPlaneOffset: 2 96 | shadowCascade2Split: 0.33333334 97 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 98 | blendWeights: 2 99 | textureQuality: 0 100 | anisotropicTextures: 1 101 | antiAliasing: 0 102 | softParticles: 0 103 | softVegetation: 1 104 | realtimeReflectionProbes: 1 105 | billboardsFaceCameraPosition: 1 106 | vSyncCount: 1 107 | lodBias: 1 108 | maximumLODLevel: 0 109 | particleRaycastBudget: 256 110 | asyncUploadTimeSlice: 2 111 | asyncUploadBufferSize: 4 112 | excludedTargetPlatforms: [] 113 | - serializedVersion: 2 114 | name: Beautiful 115 | pixelLightCount: 3 116 | shadows: 2 117 | shadowResolution: 2 118 | shadowProjection: 1 119 | shadowCascades: 2 120 | shadowDistance: 70 121 | shadowNearPlaneOffset: 2 122 | shadowCascade2Split: 0.33333334 123 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 124 | blendWeights: 4 125 | textureQuality: 0 126 | anisotropicTextures: 2 127 | antiAliasing: 2 128 | softParticles: 1 129 | softVegetation: 1 130 | realtimeReflectionProbes: 1 131 | billboardsFaceCameraPosition: 1 132 | vSyncCount: 1 133 | lodBias: 1.5 134 | maximumLODLevel: 0 135 | particleRaycastBudget: 1024 136 | asyncUploadTimeSlice: 2 137 | asyncUploadBufferSize: 4 138 | excludedTargetPlatforms: [] 139 | - serializedVersion: 2 140 | name: Fantastic 141 | pixelLightCount: 4 142 | shadows: 2 143 | shadowResolution: 2 144 | shadowProjection: 1 145 | shadowCascades: 4 146 | shadowDistance: 150 147 | shadowNearPlaneOffset: 2 148 | shadowCascade2Split: 0.33333334 149 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 150 | blendWeights: 4 151 | textureQuality: 0 152 | anisotropicTextures: 2 153 | antiAliasing: 2 154 | softParticles: 1 155 | softVegetation: 1 156 | realtimeReflectionProbes: 1 157 | billboardsFaceCameraPosition: 1 158 | vSyncCount: 1 159 | lodBias: 2 160 | maximumLODLevel: 0 161 | particleRaycastBudget: 4096 162 | asyncUploadTimeSlice: 2 163 | asyncUploadBufferSize: 4 164 | excludedTargetPlatforms: [] 165 | m_PerPlatformDefaultQuality: 166 | Android: 2 167 | BlackBerry: 2 168 | GLES Emulation: 5 169 | Nintendo 3DS: 5 170 | PS3: 5 171 | PS4: 5 172 | PSM: 5 173 | PSP2: 2 174 | Samsung TV: 2 175 | Standalone: 5 176 | Tizen: 2 177 | WP8: 5 178 | Web: 5 179 | WebGL: 3 180 | WiiU: 5 181 | Windows Store Apps: 5 182 | XBOX360: 5 183 | XboxOne: 5 184 | iPhone: 2 185 | tvOS: 5 186 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | CrashReportingSettings: 11 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 12 | m_Enabled: 0 13 | m_CaptureEditorExceptions: 1 14 | UnityPurchasingSettings: 15 | m_Enabled: 0 16 | m_TestMode: 0 17 | UnityAnalyticsSettings: 18 | m_Enabled: 0 19 | m_InitializeOnStartup: 1 20 | m_TestMode: 0 21 | m_TestEventUrl: 22 | m_TestConfigUrl: 23 | UnityAdsSettings: 24 | m_Enabled: 0 25 | m_InitializeOnStartup: 1 26 | m_TestMode: 0 27 | m_EnabledPlatforms: 4294967295 28 | m_IosGameId: 29 | m_AndroidGameId: 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity-Weld-Examples 2 | 3 | An example Unity project that demonstrates Unity-Weld. 4 | 5 | Unity-Weld is available separately on github: [https://github.com/Real-Serious-Games/Unity-Weld](https://github.com/Real-Serious-Games/Unity-Weld). 6 | 7 | A series of articles on Unity Weld has been published on [What Could Possibly Go Wrong](http://www.what-could-possibly-go-wrong.com/bringing-mvvm-to-unity-part-1-about-mvvm-and-unity-weld). 8 | 9 | -------------------------------------------------------------------------------- /UnityPackageManager/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | --------------------------------------------------------------------------------