diff --git a/Editor/AnimatorParameterBindingEditor.cs b/Editor/AnimatorParameterBindingEditor.cs index 8120a88..b82432f 100644 --- a/Editor/AnimatorParameterBindingEditor.cs +++ b/Editor/AnimatorParameterBindingEditor.cs @@ -49,8 +49,10 @@ protected override void OnInspector() return; } + BeginArea(new GUIContent("View")); + ShowAnimatorParametersMenu( - new GUIContent("View property", "Property on the view to bind to"), + new GUIContent("Property", "Property on the View to bind to"), updatedValue => { targetScript.AnimatorParameterName = updatedValue.Name; @@ -74,7 +76,7 @@ out var viewPropertyType EditorStyles.label.fontStyle = viewAdapterPrefabModified ? FontStyle.Bold : DefaultFontStyle; ShowAdapterMenu( - new GUIContent("View adapter", "Adapter that converts values sent from the view-model to the view."), + new GUIContent("Adapter", "Adapter that converts Values sent from the View-Model to the View."), viewAdapterTypeNames, targetScript.ViewAdapterId, newValue => @@ -100,30 +102,35 @@ out var viewPropertyType EditorStyles.label.fontStyle = viewAdapterOptionsPrefabModified ? FontStyle.Bold : DefaultFontStyle; ShowAdapterOptionsMenu( - "View adapter options", + "Options", adapterType, options => targetScript.ViewAdapterOptions = options, targetScript.ViewAdapterOptions, viewAdapterOptionsFade.faded ); + EndArea(); + EditorGUILayout.Space(); + + BeginArea(new GUIContent("View-Model")); EditorStyles.label.fontStyle = viewModelPropertyPrefabModified ? FontStyle.Bold : DefaultFontStyle; var adaptedViewPropertyType = AdaptTypeBackward(viewPropertyType, targetScript.ViewAdapterId); ShowViewModelPropertyMenu( - new GUIContent("View-model property", "Property on the view-model to bind to."), + new GUIContent("Property", "Property on the View-Model to bind to."), TypeResolver.FindBindableProperties(targetScript), updatedValue => targetScript.ViewModelPropertyName = updatedValue, targetScript.ViewModelPropertyName, property => property.PropertyType == adaptedViewPropertyType ); - GUI.enabled = guiPreviouslyEnabled; + EndArea(); - EditorGUILayout.Space(); + GUI.enabled = guiPreviouslyEnabled; + //EditorGUILayout.Space(); } private void ShowAnimatorParametersMenu( diff --git a/Editor/BaseBindingEditor.cs b/Editor/BaseBindingEditor.cs index e335f31..bd0ef8d 100644 --- a/Editor/BaseBindingEditor.cs +++ b/Editor/BaseBindingEditor.cs @@ -93,7 +93,7 @@ public sealed override void OnInspectorGUI() if (_autoConnectionProperty != null) { - EditorGUILayout.PropertyField(_autoConnectionProperty); + EditorGUILayout.PropertyField(_autoConnectionProperty, new GUIContent("Auto Connect", "Automatically bind once on \"OnEnable()\"")); } OnInspector(); @@ -166,6 +166,21 @@ public OptionInfo(string menuName, BindableMember property) /// private static readonly string NoneOptionString = "None"; + protected void BeginArea(GUIContent label) + { + var style = EditorStyles.label.fontStyle; + EditorStyles.label.fontStyle = FontStyle.Bold; + + EditorGUILayout.LabelField(label); + EditorGUI.indentLevel++; + + EditorStyles.label.fontStyle = style; + } + protected void EndArea() + { + EditorGUI.indentLevel--; + } + /// /// Display a popup menu for selecting a property from a view-model. /// @@ -267,6 +282,7 @@ out Type selectedPropertyType /// Show dropdown for selecting a UnityEvent to bind to. /// protected void ShowEventMenu( + GUIContent label, BindableEvent[] events, Action propertyValueSetter, string curPropertyValue @@ -281,7 +297,7 @@ string curPropertyValue .ToArray(); var newSelectedIndex = EditorGUILayout.Popup( - new GUIContent("View event", "Event on the view to bind to."), + label, selectedIndex, content ); diff --git a/Editor/CollectionBindingEditor.cs b/Editor/CollectionBindingEditor.cs index 4462a3c..359e9f8 100644 --- a/Editor/CollectionBindingEditor.cs +++ b/Editor/CollectionBindingEditor.cs @@ -28,18 +28,29 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); - EditorGUILayout.PropertyField(_templateInitialPoolCountProperty); - EditorGUILayout.PropertyField(_itemsContainerProperty); - EditorGUILayout.PropertyField(_templatesProperty, true); - + BeginArea(new GUIContent("View-Model")); + EditorStyles.label.fontStyle = _viewModelPrefabModified ? FontStyle.Bold : DefaultFontStyle; ShowViewModelPropertyMenu( - new GUIContent("View-model property", "Property on the view-model to bind to."), + new GUIContent("Property", "Property on the View-Model to bind to."), TypeResolver.FindBindableCollectionProperties(_targetScript), updatedValue => _targetScript.ViewModelPropertyName = updatedValue, _targetScript.ViewModelPropertyName, property => true ); + + EndArea(); + + EditorGUILayout.Space(); + + BeginArea(new GUIContent("Templates Settings")); + + EditorGUILayout.PropertyField(_templateInitialPoolCountProperty, new GUIContent("Initial Pool Count")); + EditorGUILayout.PropertyField(_itemsContainerProperty, new GUIContent("Container")); + + EditorGUILayout.PropertyField(_templatesProperty, new GUIContent("Templates", "Templates for Collection"), true); + + EndArea(); } /// diff --git a/Editor/EventBindingEditor.cs b/Editor/EventBindingEditor.cs index 808432b..f490203 100644 --- a/Editor/EventBindingEditor.cs +++ b/Editor/EventBindingEditor.cs @@ -25,11 +25,14 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); + BeginArea(new GUIContent("View")); + EditorStyles.label.fontStyle = viewEventPrefabModified ? FontStyle.Bold : DefaultFontStyle; ShowEventMenu( + new GUIContent("Event", "Event on the View to bind to."), UnityEventWatcher.GetBindableEvents(targetScript.gameObject) .OrderBy(evt => evt.Name) .ToArray(), @@ -37,26 +40,33 @@ protected override void OnInspector() targetScript.ViewEventName ); + EndArea(); + + EditorGUILayout.Space(); + + BeginArea(new GUIContent("View-Model")); + EditorStyles.label.fontStyle = viewModelMethodPrefabModified ? FontStyle.Bold : DefaultFontStyle; - ShowMethodMenu(targetScript, TypeResolver.FindBindableMethods(targetScript)); + ShowMethodMenu(new GUIContent("Method", "Method on the view - model to bind to."), targetScript, TypeResolver.FindBindableMethods(targetScript)); + + EndArea(); } /// /// Draws the dropdown for selecting a method from bindableViewModelMethods /// private void ShowMethodMenu( + GUIContent label, EventBinding targetScript, BindableMember[] bindableMethods ) { - var tooltip = "Method on the view-model to bind to."; - InspectorUtils.DoPopup( new GUIContent(targetScript.ViewModelMethodName), - new GUIContent("View-model method", tooltip), + label, m => m.ViewModelType + "/" + m.MemberName, m => true, m => m.ToString() == targetScript.ViewModelMethodName, diff --git a/Editor/OneWayPropertyBindingEditor.cs b/Editor/OneWayPropertyBindingEditor.cs index 23634db..3e93527 100644 --- a/Editor/OneWayPropertyBindingEditor.cs +++ b/Editor/OneWayPropertyBindingEditor.cs @@ -39,14 +39,17 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); - var defaultLabelStyle = EditorStyles.label.fontStyle; + //var defaultLabelStyle = EditorStyles.label.fontStyle; + + BeginArea(new GUIContent("View")); + EditorStyles.label.fontStyle = viewPropertyPrefabModified ? FontStyle.Bold - : defaultLabelStyle; + : DefaultFontStyle; Type viewPropertyType; ShowViewPropertyMenu( - new GUIContent("View property", "Property on the view to bind to"), + new GUIContent("Property", "Property on the View to bind to"), PropertyFinder.GetBindableProperties(targetScript.gameObject), updatedValue => targetScript.ViewPropertyName = updatedValue, targetScript.ViewPropertyName, @@ -65,12 +68,12 @@ out viewPropertyType EditorStyles.label.fontStyle = viewAdapterPrefabModified ? FontStyle.Bold - : defaultLabelStyle; + : DefaultFontStyle; ShowAdapterMenu( new GUIContent( - "View adapter", - "Adapter that converts values sent from the view-model to the view." + "Adapter", + "Adapter that converts values sent from the View-Model to the View." ), viewAdapterTypeNames, targetScript.ViewAdapterId, @@ -79,7 +82,7 @@ out viewPropertyType // Get rid of old adapter options if we changed the type of the adapter. if (newValue != targetScript.ViewAdapterId) { - Undo.RecordObject(targetScript, "Set view adapter options"); + Undo.RecordObject(targetScript, "Set view adapter Options"); targetScript.ViewAdapterOptions = null; } @@ -87,7 +90,7 @@ out viewPropertyType updatedValue => targetScript.ViewAdapterId = updatedValue, targetScript.ViewAdapterId, newValue, - "Set view adapter" + "Set View Adapter" ); } ); @@ -100,21 +103,25 @@ out adapterType EditorStyles.label.fontStyle = viewAdapterOptionsPrefabModified ? FontStyle.Bold - : defaultLabelStyle; + : DefaultFontStyle; ShowAdapterOptionsMenu( - "View adapter options", + "Options", adapterType, options => targetScript.ViewAdapterOptions = options, targetScript.ViewAdapterOptions, viewAdapterOptionsFade.faded ); + EndArea(); + EditorGUILayout.Space(); + BeginArea(new GUIContent("View-Model")); + EditorStyles.label.fontStyle = viewModelPropertyPrefabModified ? FontStyle.Bold - : defaultLabelStyle; + : DefaultFontStyle; var adaptedViewPropertyType = AdaptTypeBackward( viewPropertyType, @@ -122,8 +129,8 @@ out adapterType ); ShowViewModelPropertyMenu( new GUIContent( - "View-model property", - "Property on the view-model to bind to." + "Property", + "Property on the View-Model to bind To." ), TypeResolver.FindBindableProperties(targetScript), updatedValue => targetScript.ViewModelPropertyName = updatedValue, @@ -131,9 +138,11 @@ out adapterType property => property.PropertyType == adaptedViewPropertyType ); + EndArea(); + GUI.enabled = guiPreviouslyEnabled; - EditorStyles.label.fontStyle = defaultLabelStyle; + //EditorStyles.label.fontStyle = DefaultFontStyle; } /// diff --git a/Editor/SubViewModelBindingEditor.cs b/Editor/SubViewModelBindingEditor.cs index c0a0751..8d67e11 100644 --- a/Editor/SubViewModelBindingEditor.cs +++ b/Editor/SubViewModelBindingEditor.cs @@ -29,6 +29,8 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); + BeginArea(new GUIContent("Sub View-Model")); + var bindableProperties = FindBindableProperties(); EditorStyles.label.fontStyle = propertyPrefabModified @@ -37,8 +39,8 @@ protected override void OnInspector() ShowViewModelPropertyMenu( new GUIContent( - "Sub view-model property", - "The property on the top level view model containing the sub view-model" + "Property", + "The Property on the top level View-Model containing the Sub View-Model" ), bindableProperties, updatedValue => @@ -52,6 +54,8 @@ protected override void OnInspector() targetScript.ViewModelPropertyName, p => true ); + + EndArea(); } private BindableMember[] FindBindableProperties() diff --git a/Editor/TemplateBindingEditor.cs b/Editor/TemplateBindingEditor.cs index 221d4be..e6496ce 100644 --- a/Editor/TemplateBindingEditor.cs +++ b/Editor/TemplateBindingEditor.cs @@ -23,14 +23,16 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); + BeginArea(new GUIContent("Template")); + EditorStyles.label.fontStyle = viewModelPrefabModified ? FontStyle.Bold : DefaultFontStyle; ShowViewModelPropertyMenu( new GUIContent( - "Template property", - "Property on the view model to use for selecting templates." + "Property", + "Property on the View-Model to use for selecting Templates." ), TypeResolver.FindBindableProperties(targetScript), updatedValue => targetScript.ViewModelPropertyName = updatedValue, @@ -38,7 +40,9 @@ protected override void OnInspector() property => true ); - EditorGUILayout.PropertyField(_templatesProperty, true); + EndArea(); + + EditorGUILayout.PropertyField(_templatesProperty, new GUIContent("Templates", "Templates for Collection"), true); } /// diff --git a/Editor/TemplateEditor.cs b/Editor/TemplateEditor.cs index 106773c..063b100 100644 --- a/Editor/TemplateEditor.cs +++ b/Editor/TemplateEditor.cs @@ -30,6 +30,8 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); + BeginArea(new GUIContent("Template")); + var availableViewModels = TypeResolver.TypesWithBindingAttribute .Select(type => type.ToString()) .OrderBy(name => name) @@ -46,8 +48,8 @@ protected override void OnInspector() var newSelectedIndex = EditorGUILayout.Popup( new GUIContent( - "Template view model", - "Type of the view model that this template will be bound to when it is instantiated." + "View-Model", + "Type of the View-Model that this Template will be bound to when it is instantiated." ), selectedIndex, availableViewModels @@ -66,6 +68,8 @@ protected override void OnInspector() : availableViewModels[newSelectedIndex], "Set bound view-model for template" ); + + EndArea(); } /// diff --git a/Editor/ToggleActiveBindingEditor.cs b/Editor/ToggleActiveBindingEditor.cs index 61485f2..c61b87d 100644 --- a/Editor/ToggleActiveBindingEditor.cs +++ b/Editor/ToggleActiveBindingEditor.cs @@ -35,6 +35,9 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); + + BeginArea(new GUIContent("View")); + var viewPropertyType = typeof(bool); var viewAdapterTypeNames = TypeResolver.GetAdapterIds(o => o.OutType == viewPropertyType); @@ -45,8 +48,8 @@ protected override void OnInspector() ShowAdapterMenu( new GUIContent( - "View adapter", - "Adapter that converts values sent from the view-model to the view." + "Adapter", + "Adapter that converts values sent from the View-Model to the View." ), viewAdapterTypeNames, targetScript.ViewAdapterId, @@ -79,15 +82,19 @@ out adapterType : DefaultFontStyle; ShowAdapterOptionsMenu( - "View adapter options", + "Options", adapterType, options => targetScript.ViewAdapterOptions = options, targetScript.ViewAdapterOptions, viewAdapterOptionsFade.faded ); + EndArea(); + EditorGUILayout.Space(); + BeginArea(new GUIContent("View-Model")); + EditorStyles.label.fontStyle = viewModelPropertyPrefabModified ? FontStyle.Bold : DefaultFontStyle; @@ -98,14 +105,16 @@ out adapterType ); ShowViewModelPropertyMenu( new GUIContent( - "View-model property", - "Property on the view-model to bind to." + "Property", + "Property on the View-Model to bind to." ), TypeResolver.FindBindableProperties(targetScript), updatedValue => targetScript.ViewModelPropertyName = updatedValue, targetScript.ViewModelPropertyName, property => property.PropertyType == adaptedViewPropertyType ); + + EndArea(); } private void UpdatePrefabModifiedProperties() diff --git a/Editor/TwoWayPropertyBindingEditor.cs b/Editor/TwoWayPropertyBindingEditor.cs index cd0c93e..5e09cf8 100644 --- a/Editor/TwoWayPropertyBindingEditor.cs +++ b/Editor/TwoWayPropertyBindingEditor.cs @@ -56,11 +56,14 @@ protected override void OnInspector() { UpdatePrefabModifiedProperties(); + BeginArea(new GUIContent("View")); + EditorStyles.label.fontStyle = viewEventPrefabModified ? FontStyle.Bold : DefaultFontStyle; ShowEventMenu( + new GUIContent("Event", "Event on the View to bind to."), UnityEventWatcher.GetBindableEvents(targetScript.gameObject) .OrderBy(evt => evt.Name) .ToArray(), @@ -74,7 +77,7 @@ protected override void OnInspector() Type viewPropertyType; ShowViewPropertyMenu( - new GUIContent("View property", "Property on the view to bind to"), + new GUIContent("Property", "Property on the View to bind to"), PropertyFinder.GetBindableProperties(targetScript.gameObject), updatedValue => targetScript.ViewPropertyName = updatedValue, targetScript.ViewPropertyName, @@ -98,8 +101,8 @@ out viewPropertyType ShowAdapterMenu( new GUIContent( - "View adapter", - "Adapter that converts values sent from the view-model to the view." + "Adapter", + "Adapter that converts values sent from the View-Model to the View." ), viewAdapterTypeNames, targetScript.ViewAdapterId, @@ -131,15 +134,19 @@ out viewPropertyType out viewAdapterType ); ShowAdapterOptionsMenu( - "View adapter options", + "Options", viewAdapterType, options => targetScript.ViewAdapterOptions = options, targetScript.ViewAdapterOptions, viewAdapterOptionsFade.faded ); + EndArea(); + EditorGUILayout.Space(); + BeginArea(new GUIContent("View-Model")); + EditorStyles.label.fontStyle = viewModelPropertyPrefabModified ? FontStyle.Bold : DefaultFontStyle; @@ -150,8 +157,8 @@ out viewAdapterType ); ShowViewModelPropertyMenu( new GUIContent( - "View-model property", - "Property on the view-model to bind to." + "Property", + "Property on the View-Model to bind to." ), TypeResolver.FindBindableProperties(targetScript), updatedValue => targetScript.ViewModelPropertyName = updatedValue, @@ -168,8 +175,8 @@ out viewAdapterType ShowAdapterMenu( new GUIContent( - "View-model adapter", - "Adapter that converts from the view back to the view-model" + "Adapter", + "Adapter that converts from the View back to the View-Model" ), viewModelAdapterTypeNames, targetScript.ViewModelAdapterId, @@ -200,15 +207,19 @@ out viewAdapterType out viewModelAdapterType ); ShowAdapterOptionsMenu( - "View-model adapter options", + "Options", viewModelAdapterType, options => targetScript.ViewModelAdapterOptions = options, targetScript.ViewModelAdapterOptions, viewModelAdapterOptionsFade.faded ); + EndArea(); + EditorGUILayout.Space(); + BeginArea(new GUIContent("Exception")); + var expectionAdapterTypeNames = TypeResolver.GetAdapterIds( o => o.InType == typeof(Exception)); @@ -222,8 +233,8 @@ out viewModelAdapterType ); ShowViewModelPropertyMenuWithNone( new GUIContent( - "Exception property", - "Property on the view-model to bind the exception to." + "Property", + "Property on the View-Model to bind the Exception to." ), TypeResolver.FindBindableProperties(targetScript), updatedValue => targetScript.ExceptionPropertyName = updatedValue, @@ -237,8 +248,8 @@ out viewModelAdapterType ShowAdapterMenu( new GUIContent( - "Exception adapter", - "Adapter that handles exceptions thrown by the view-model adapter" + "Adapter", + "Adapter that handles Exceptions thrown by the View-Model Adapter" ), expectionAdapterTypeNames, targetScript.ExceptionAdapterTypeName, @@ -269,13 +280,15 @@ out viewModelAdapterType out exceptionAdapterType ); ShowAdapterOptionsMenu( - "Exception adapter options", + "Options", exceptionAdapterType, options => targetScript.ExceptionAdapterOptions = options, targetScript.ExceptionAdapterOptions, exceptionAdapterOptionsFade.faded ); + EndArea(); + GUI.enabled = guiPreviouslyEnabled; } diff --git a/Runtime/Binding/AbstractMemberBinding.cs b/Runtime/Binding/AbstractMemberBinding.cs index b3e9324..0d3c108 100644 --- a/Runtime/Binding/AbstractMemberBinding.cs +++ b/Runtime/Binding/AbstractMemberBinding.cs @@ -13,7 +13,8 @@ public abstract class AbstractMemberBinding : MonoBehaviour, IMemberBinding { private bool _isInitCalled; - [SerializeField, Header("Automatically bind once on \"OnEnable()\"")] + //[Header("Automatically bind once on \"OnEnable()\"")] + [SerializeField] private bool _isAutoConnection; diff --git a/Runtime/Binding/AbstractTemplateSelector.cs b/Runtime/Binding/AbstractTemplateSelector.cs index 49512b5..1908b6a 100644 --- a/Runtime/Binding/AbstractTemplateSelector.cs +++ b/Runtime/Binding/AbstractTemplateSelector.cs @@ -10,7 +10,7 @@ namespace UnityWeld.Binding { public abstract class AbstractTemplateSelector : AbstractMemberBinding { - [Header("Set templates for collection")] + //[Header("Set templates for collection")] [SerializeField] private Template[] _templates; [SerializeField] private string viewModelPropertyName = string.Empty;