diff --git a/Assets/Editor Toolbox/CHANGELOG.md b/Assets/Editor Toolbox/CHANGELOG.md index fb3a1f03..f90251c6 100644 --- a/Assets/Editor Toolbox/CHANGELOG.md +++ b/Assets/Editor Toolbox/CHANGELOG.md @@ -1,3 +1,12 @@ +## 0.8.13 [04.07.2021] + +### Added: +- Begin/EndHorizontalGroupAttribute + +### Changed: +- Fix overall layouting issues +- Fix IgnoreParentAttribute issues + ## 0.8.11 [02.07.2021] ### Added: diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxNativePropertyDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ToolboxNativePropertyDrawer.cs similarity index 100% rename from Assets/Editor Toolbox/Editor/Drawers/ToolboxNativePropertyDrawer.cs rename to Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ToolboxNativePropertyDrawer.cs diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxNativePropertyDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ToolboxNativePropertyDrawer.cs.meta similarity index 100% rename from Assets/Editor Toolbox/Editor/Drawers/ToolboxNativePropertyDrawer.cs.meta rename to Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ToolboxNativePropertyDrawer.cs.meta diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages.meta b/Assets/Editor Toolbox/Editor/Drawers/Storages.meta new file mode 100644 index 00000000..065cb78f --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 585b8e2c7a46a524aba7e6e4a0683b36 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/ControlDataStorage.cs b/Assets/Editor Toolbox/Editor/Drawers/Storages/ControlDataStorage.cs new file mode 100644 index 00000000..95a24f22 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/ControlDataStorage.cs @@ -0,0 +1,24 @@ +using System; + +using UnityEngine; + +namespace Toolbox.Editor.Drawers +{ + public class ControlDataStorage : DrawerDataStorage + { + public ControlDataStorage(Func createMethod) : base(createMethod) + { } + + + protected override string GetKey(int context) + { + return context.ToString(); + } + + + public int GetControlId() + { + return GUIUtility.GetControlID(FocusType.Passive); + } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/ControlDataStorage.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/Storages/ControlDataStorage.cs.meta new file mode 100644 index 00000000..7d868b51 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/ControlDataStorage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b017609e4fff016488a238d7eb2e1ec6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorage.cs b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorage.cs new file mode 100644 index 00000000..b038df5e --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorage.cs @@ -0,0 +1,102 @@ +using System.Collections.Generic; +using System; + +namespace Toolbox.Editor.Drawers +{ + /// + /// Internal system responsible for keeping and clearing data between s. + /// This small system works only for attribute-based drawers and should be defined as a static field. + /// + /// Key-related object. + /// Data to store. + /// Any type needed for storage item creation. Pass if no additional data is needed. + public abstract class DrawerDataStorage : DrawerDataStorageBase + { + protected readonly Dictionary items = new Dictionary(); + + protected readonly Func createMethod; + protected readonly Action removeMethod; + + + public DrawerDataStorage(Func createMethod) : this(createMethod, null) + { } + + public DrawerDataStorage(Func createMethod, Action removeMethod) + { + this.createMethod = createMethod; + this.removeMethod = removeMethod; + } + + + protected abstract string GetKey(T context); + + + /// + /// Returns and if needed creates new item. + /// + public virtual T1 ReturnItem(T context, T2 args) + { + var key = GetKey(context); + if (items.TryGetValue(key, out var item)) + { + return item; + } + else + { + return items[key] = CreateItem(context, args); + } + } + + public virtual T1 CreateItem(T context, T2 args) + { + return CreateItem(context, args, true); + } + + public virtual T1 CreateItem(T context, T2 args, bool append) + { + var item = createMethod(context, args); + if (append) + { + AppendItem(context, item); + } + + return item; + } + + public virtual T1 AppendItem(T context, T1 item) + { + var key = GetKey(context); + return items[key] = item; + } + + public virtual void ClearItem(T context) + { + var key = GetKey(context); + if (removeMethod != null) + { + if (items.TryGetValue(key, out var value)) + { + removeMethod(value); + items.Remove(key); + } + } + else + { + items.Remove(key); + } + } + + public override void ClearItems() + { + if (removeMethod != null) + { + foreach (var item in items.Values) + { + removeMethod(item); + } + } + + items.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Internal/DrawerDataStorage.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorage.cs.meta similarity index 83% rename from Assets/Editor Toolbox/Editor/Internal/DrawerDataStorage.cs.meta rename to Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorage.cs.meta index 97d76664..3e3376c4 100644 --- a/Assets/Editor Toolbox/Editor/Internal/DrawerDataStorage.cs.meta +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorage.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d44d84f2e729b05449db8c912fe8dffe +guid: f8ae6cb9b3ffe1349bc87f909df163ee MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorageBase.cs b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorageBase.cs new file mode 100644 index 00000000..56c7d928 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorageBase.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; + +namespace Toolbox.Editor.Drawers +{ + public abstract class DrawerDataStorageBase + { + static DrawerDataStorageBase() + { + InspectorUtility.OnEditorReload += () => + { + for (var i = 0; i < storages.Count; i++) + { + storages[i].ClearItems(); + } + }; + } + + + protected DrawerDataStorageBase() + { + storages.Add(this); + } + + ~DrawerDataStorageBase() + { + storages.Remove(this); + } + + + private static readonly List storages = new List(); + + + /// + /// Called each time Editor is completely destroyed. + /// + public abstract void ClearItems(); + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorageBase.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorageBase.cs.meta new file mode 100644 index 00000000..37f13fc2 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/DrawerDataStorageBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c13a6da2d6177824ea454ff1d7b723da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/PropertyDataStorage.cs b/Assets/Editor Toolbox/Editor/Drawers/Storages/PropertyDataStorage.cs new file mode 100644 index 00000000..c22c1437 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/PropertyDataStorage.cs @@ -0,0 +1,49 @@ +using System; + +using UnityEditor; + +namespace Toolbox.Editor.Drawers +{ + public class PropertyDataStorage : DrawerDataStorage + { + private readonly bool isPersistant; + + + public PropertyDataStorage(bool isPersistant, Func createMethod) : this(isPersistant, createMethod, null) + { } + + public PropertyDataStorage(bool isPersistant, Func createMethod, Action removeMethod) : base (createMethod, removeMethod) + { + this.isPersistant = isPersistant; + } + + + protected override string GetKey(SerializedProperty property) + { + return isPersistant + ? property.GetPropertyTypeKey() + : property.GetPropertyHashKey(); + } + + + public override void ClearItems() + { + if (isPersistant) + { + return; + } + else + { + if (removeMethod != null) + { + foreach (var item in items.Values) + { + removeMethod(item); + } + } + + items.Clear(); + } + } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/Storages/PropertyDataStorage.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/Storages/PropertyDataStorage.cs.meta new file mode 100644 index 00000000..62c08885 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Storages/PropertyDataStorage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fdb7229c9f954bc41a43b198a6c708f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalAttributeDrawer.cs index 6fe6d024..ae039601 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalAttributeDrawer.cs @@ -8,7 +8,7 @@ public class BeginHorizontalAttributeDrawer : ToolboxDecoratorDrawer + { + static BeginHorizontalGroupAttributeDrawer() + { + storage = new ControlDataStorage((id, defaultValue) => + { + return defaultValue; + }); + } + + /// + /// Storage used to cache scroll values depending on the given control ID. + /// + private static readonly ControlDataStorage storage; + + + private void HandleScrollView(float fixedHeight) + { + var controlId = storage.GetControlId(); + var oldScroll = storage.ReturnItem(controlId, Vector2.zero); + var newScroll = fixedHeight > 0.0f + ? EditorGUILayout.BeginScrollView(oldScroll, GUILayout.Height(fixedHeight)) + : EditorGUILayout.BeginScrollView(oldScroll); + storage.AppendItem(controlId, newScroll); + } + + private void ApplyIndentLevel() + { + GUILayout.Space(Style.extraIndentLevel); + } + + + protected override void OnGuiBeginSafe(BeginHorizontalGroupAttribute attribute) + { + var fixedWidth = EditorGUIUtility.currentViewWidth; + var fixedHeight = attribute.Height; + EditorGUIUtility.labelWidth = fixedWidth * attribute.LabelToWidthRatio; + EditorGUIUtility.fieldWidth = fixedWidth * attribute.FieldToWidthRatio; + + ToolboxLayoutHelper.BeginVertical(Style.groupBackgroundStyle); + if (attribute.HasLabel) + { + GUILayout.Label(attribute.Label, EditorStyles.boldLabel); + } + + HandleScrollView(fixedHeight); + ToolboxLayoutHelper.BeginHorizontal(); + ApplyIndentLevel(); + } + + + private static class Style + { + /// + /// Additional indent applied to keep foldout-based labels within the group. + /// + internal static readonly float extraIndentLevel = 8.0f; + + internal static readonly GUIStyle groupBackgroundStyle; + + static Style() + { +#if UNITY_2019_3_OR_NEWER + groupBackgroundStyle = new GUIStyle("helpBox") +#else + groupBackgroundStyle = new GUIStyle("box") +#endif + { + padding = new RectOffset(13, 12, 5, 5) + }; + } + } + } +} diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs.meta new file mode 100644 index 00000000..71d7b539 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 916b488f13debc149a401b405cd684ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/EndHorizontalGroupAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/EndHorizontalGroupAttributeDrawer.cs new file mode 100644 index 00000000..addc06af --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/EndHorizontalGroupAttributeDrawer.cs @@ -0,0 +1,18 @@ +using UnityEditor; +using UnityEngine; + +namespace Toolbox.Editor.Drawers +{ + public class EndHorizontalGroupAttributeDrawer : ToolboxDecoratorDrawer + { + protected override void OnGuiCloseSafe(EndHorizontalGroupAttribute attribute) + { + ToolboxLayoutHelper.CloseHorizontal(); + EditorGUILayout.EndScrollView(); + ToolboxLayoutHelper.CloseVertical(); + + EditorGUIUtility.labelWidth = 0.0f; + EditorGUIUtility.fieldWidth = 0.0f; + } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/EndHorizontalGroupAttributeDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/EndHorizontalGroupAttributeDrawer.cs.meta new file mode 100644 index 00000000..d3ffa5bb --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/EndHorizontalGroupAttributeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 736c8d5185d16a2459f4b1fdd6e0c4b7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/LineAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/LineAttributeDrawer.cs index b330c945..ca3c6755 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/LineAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/LineAttributeDrawer.cs @@ -6,7 +6,11 @@ public class LineAttributeDrawer : ToolboxDecoratorDrawer { protected override void OnGuiBeginSafe(LineAttribute attribute) { - ToolboxEditorGui.DrawLine(attribute.Thickness, attribute.Padding, attribute.GuiColor, attribute.ApplyIndent); + ToolboxEditorGui.DrawLine(attribute.Thickness, + attribute.Padding, + attribute.GuiColor, + attribute.IsHorizontal, + attribute.ApplyIndent); } } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs index 7e2ef955..40be98ea 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs @@ -9,7 +9,7 @@ public class ReorderableListAttributeDrawer : ToolboxListPropertyDrawer(false, (p, a) => + storage = new PropertyDataStorage(false, (p, a) => { return ToolboxEditorGui.CreateList(p, a.ListStyle, @@ -21,7 +21,7 @@ static ReorderableListAttributeDrawer() }); } - private static readonly DrawerDataStorage storage; + private static readonly PropertyDataStorage storage; /// diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs index 56c2b530..93834b2a 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs @@ -12,7 +12,7 @@ public class ReorderableListExposedAttributeDrawer : ToolboxListPropertyDrawer(false, (p, a) => + storage = new PropertyDataStorage(false, (p, a) => { //create list in the standard way var list = ToolboxEditorGui.CreateList(p, @@ -28,7 +28,7 @@ static ReorderableListExposedAttributeDrawer() }); } - private static readonly DrawerDataStorage storage; + private static readonly PropertyDataStorage storage; private static void ConnectCallbacks(ReorderableListBase list, ReorderableListExposedAttribute attribute) @@ -47,7 +47,6 @@ private static void ConnectCallbacks(ReorderableListBase list, ReorderableListEx { return methodInfo.Invoke(listTarget.targetObject, null); }; - //TODO: add more useful callbacks to expose } private static MethodInfo FindMethod(SerializedObject target, string methodName, Type expectedReturnType = null) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ScrollableItemsAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ScrollableItemsAttributeDrawer.cs index 98b3bafc..bfc01460 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ScrollableItemsAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ScrollableItemsAttributeDrawer.cs @@ -9,13 +9,13 @@ public class ScrollableItemsAttributeDrawer : ToolboxListPropertyDrawer(true, (p, a) => + storage = new PropertyDataStorage(true, (p, a) => { return new Vector2(a.DefaultMinIndex, a.DefaultMaxIndex); }); } - private static readonly DrawerDataStorage storage; + private static readonly PropertyDataStorage storage; private void DrawSettingsBody(SerializedProperty property, ScrollableItemsAttribute attribute, out int size, out Vector2 indexRange) @@ -34,7 +34,7 @@ private void DrawSettingsBody(SerializedProperty property, ScrollableItemsAttrib //fix values to the integral part indexRange.x = Mathf.Max(Mathf.RoundToInt(indexRange.x), 0); indexRange.y = Mathf.Min(Mathf.RoundToInt(indexRange.y), size); - storage.ApplyItem(property, indexRange); + storage.AppendItem(property, indexRange); } private void DrawElementsBody(SerializedProperty property, ScrollableItemsAttribute attribute, int size, Vector2 indexRange) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/IgnoreParentAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/IgnoreParentAttributeDrawer.cs index d718165a..e89a3cec 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/IgnoreParentAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/IgnoreParentAttributeDrawer.cs @@ -7,21 +7,13 @@ public class IgnoreParentAttributeDrawer : ToolboxSelfPropertyDrawer targetDepth) - { - break; - } - - //draw all children in order but only one level depth - ToolboxEditorGui.DrawToolboxProperty(targetProperty.Copy()); + ToolboxEditorGui.DrawNativeProperty(property, label); + return; } + + ToolboxEditorGui.DrawPropertyChildren(property); } } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs index 00e7e549..7c87c101 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs @@ -11,7 +11,7 @@ public class InLineEditorAttributeDrawer : ToolboxSelfPropertyDrawer(false, + storage = new PropertyDataStorage(false, (p, a) => { var value = p.objectReferenceValue; @@ -36,7 +36,7 @@ static InLineEditorAttributeDrawer() }); } - private static readonly DrawerDataStorage storage; + private static readonly PropertyDataStorage storage; private void DrawEditor(Editor editor, InLineEditorAttribute attribute) @@ -110,7 +110,9 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label, } property.isExpanded = GUILayout.Toggle(property.isExpanded, - Style.foldoutContent, Style.foldoutStyle, Style.foldoutOptions); + Style.foldoutContent, + Style.foldoutStyle, + Style.foldoutOptions); } //create additional Editor for the associated reference @@ -120,7 +122,7 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label, if (editor.target != property.objectReferenceValue) { //validate target value change (e.g. list reorder) - editor = storage.ApplyItem(property, attribute); + editor = storage.CreateItem(property, attribute); } InspectorUtility.SetIsEditorExpanded(editor, true); diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/TargetTypeDrawers/SerializedDictionaryDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/TargetTypeDrawers/SerializedDictionaryDrawer.cs index 1906608a..eb702155 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/TargetTypeDrawers/SerializedDictionaryDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/TargetTypeDrawers/SerializedDictionaryDrawer.cs @@ -12,7 +12,7 @@ public class SerializedDictionaryDrawer : ToolboxTargetTypeDrawer { static SerializedDictionaryDrawer() { - storage = new DrawerDataStorage(false, (p, a) => + storage = new PropertyDataStorage(false, (p, a) => { var pairsProperty = a.pairsProperty; var errorProperty = a.errorProperty; @@ -22,7 +22,7 @@ static SerializedDictionaryDrawer() { //cache preprocessed label to get prefab related functions var label = EditorGUI.BeginProperty(rect, null, p); - //create additional warning message if there is key collision + //create additional warning message if there is a collision if (errorProperty.boolValue) { label.image = EditorGuiUtility.GetHelpIcon(MessageType.Warning); @@ -58,7 +58,7 @@ static SerializedDictionaryDrawer() }); } - private static readonly DrawerDataStorage storage; + private static readonly PropertyDataStorage storage; public override void OnGui(SerializedProperty property, GUIContent label) diff --git a/Assets/Editor Toolbox/Editor/Internal/DrawerDataStorage.cs b/Assets/Editor Toolbox/Editor/Internal/DrawerDataStorage.cs deleted file mode 100644 index 2b461243..00000000 --- a/Assets/Editor Toolbox/Editor/Internal/DrawerDataStorage.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; - -using UnityEditor; - -namespace Toolbox.Editor.Internal -{ - abstract class DrawerDataStorage - { - static DrawerDataStorage() - { - InspectorUtility.OnEditorReload += () => - { - for (var i = 0; i < storages.Count; i++) - { - storages[i].ClearItems(); - } - }; - } - - - protected DrawerDataStorage() - { - storages.Add(this); - } - - - //TODO: clean up - private static readonly List storages = new List(); - - - public abstract void ClearItems(); - } - - /// - /// Internal system responsible for keeping and clearing data between s. - /// This small system works only for attribute-based drawers and should be defined as a static field. - /// - /// Data to store. - /// Any type needed for storage item creation. Pass if no additional data is needed. - internal class DrawerDataStorage : DrawerDataStorage - { - internal DrawerDataStorage(bool isPersistant, Func createMethod) : this(isPersistant, createMethod, null) - { } - - internal DrawerDataStorage(bool isPersistant, Func createMethod, Action removeMethod) - { - this.isPersistant = isPersistant; - this.createMethod = createMethod; - this.removeMethod = removeMethod; - } - - - private readonly bool isPersistant; - - private readonly Dictionary items = new Dictionary(); - - private readonly Func createMethod; - private readonly Action removeMethod; - - - private string GetKey(SerializedProperty property) - { - return isPersistant - ? property.GetPropertyTypeKey() - : property.GetPropertyHashKey(); - } - - public T ReturnItem(SerializedProperty property, T1 args) - { - var key = GetKey(property); - if (items.TryGetValue(key, out T item)) - { - return item; - } - else - { - return items[key] = CreateItem(property, args); - } - } - - public T CreateItem(SerializedProperty property, T1 args) - { - return createMethod(property, args); - } - - public T ApplyItem(SerializedProperty property, T1 args) - { - return ApplyItem(property, createMethod(property, args)); - } - - public T ApplyItem(SerializedProperty property, T item) - { - var key = GetKey(property); - return items[key] = item; - } - - public void ClearItem(SerializedProperty property) - { - var key = GetKey(property); - - if (removeMethod != null) - { - if (items.TryGetValue(key, out T value)) - { - removeMethod(value); - items.Remove(key); - } - } - else - { - items.Remove(key); - } - } - - public override void ClearItems() - { - if (isPersistant) - { - return; - } - else - { - if (removeMethod != null) - { - foreach (var item in items.Values) - { - removeMethod(item); - } - } - - items.Clear(); - } - } - } -} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Internal/PropertyScope.cs b/Assets/Editor Toolbox/Editor/Internal/PropertyScope.cs index 5c68b7a8..fd08da9e 100644 --- a/Assets/Editor Toolbox/Editor/Internal/PropertyScope.cs +++ b/Assets/Editor Toolbox/Editor/Internal/PropertyScope.cs @@ -1,7 +1,6 @@ using System; - -using UnityEngine; using UnityEditor; +using UnityEngine; namespace Toolbox.Editor.Internal { @@ -13,21 +12,13 @@ internal class PropertyScope : IDisposable { private readonly SerializedProperty property; - public PropertyScope(SerializedProperty property, GUIContent label, Action drawLabelAction = null) + public PropertyScope(SerializedProperty property, GUIContent label) { this.property = property; - using (var labelScope = new EditorGUILayout.VerticalScope()) - { - label = EditorGUI.BeginProperty(labelScope.rect, label, property); - if (drawLabelAction != null) - { - drawLabelAction(label); - } - else - { - property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label, true); - } - } + var rowHeight = EditorGUIUtility.singleLineHeight; + var labelRect = EditorGUILayout.GetControlRect(true, rowHeight); + label = EditorGUI.BeginProperty(labelRect, label, property); + property.isExpanded = EditorGUI.Foldout(labelRect, property.isExpanded, label, true); } public void Dispose() diff --git a/Assets/Editor Toolbox/Editor/ToolboxEditor.cs b/Assets/Editor Toolbox/Editor/ToolboxEditor.cs index 6da80084..0e38b6ec 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxEditor.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxEditor.cs @@ -88,7 +88,7 @@ public virtual void DrawCustomInspector() public static event Action OnBeginToolboxEditor; - public static event Action OnBreakToolboxEditor; + public static event Action OnBreakToolboxEditor; public static event Action OnCloseToolboxEditor; } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs b/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs index dc0ba312..977f1d2b 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs @@ -12,6 +12,14 @@ namespace Toolbox.Editor /// public static partial class ToolboxEditorGui { + private static Rect GetLineRect(Rect rect, float thickness, float padding, bool horizontal) + { + return horizontal + ? new Rect(rect.x, rect.y + padding / 2, rect.width, thickness) + : new Rect(rect.x + padding / 2, rect.y, thickness, rect.height); + } + + /// /// Draws horizontal line. /// Uses built-in layouting system. @@ -27,22 +35,34 @@ public static void DrawLine(float thickness = 0.75f, float padding = 6.0f) /// public static void DrawLine(float thickness, float padding, Color color) { - DrawLine(thickness, padding, color, false); + DrawLine(thickness, padding, color, true); } /// /// Draws horizontal line. /// Uses built-in layouting system. /// - public static void DrawLine(float thickness, float padding, Color color, bool applyIndent) + public static void DrawLine(float thickness, float padding, Color color, bool horizontal) { - var rect = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness)); + DrawLine(thickness, padding, color, horizontal, false); + } + + /// + /// Draws horizontal line. + /// Uses built-in layouting system. + /// + public static void DrawLine(float thickness, float padding, Color color, bool horizontal, bool applyIndent) + { + var area = padding + thickness; + var rect = horizontal + ? EditorGUILayout.GetControlRect(GUILayout.Height(area), GUILayout.ExpandWidth(true)) + : EditorGUILayout.GetControlRect(GUILayout.Width(area), GUILayout.ExpandHeight(true)); if (applyIndent) { rect = EditorGUI.IndentedRect(rect); } - DrawLine(rect, thickness, padding, color); + DrawLine(rect, thickness, padding, color, horizontal); } /// @@ -50,16 +70,15 @@ public static void DrawLine(float thickness, float padding, Color color, bool ap /// public static void DrawLine(Rect rect, float thickness = 0.75f, float padding = 6.0f) { - DrawLine(rect, thickness, padding, new Color(0.3f, 0.3f, 0.3f)); + DrawLine(rect, thickness, padding, new Color(0.3f, 0.3f, 0.3f), true); } /// /// Draws horizontal line. /// - public static void DrawLine(Rect rect, float thickness, float padding, Color color) + public static void DrawLine(Rect rect, float thickness, float padding, Color color, bool horizontal) { - rect = new Rect(rect.x, rect.y + padding / 2, rect.width, thickness); - EditorGUI.DrawRect(rect, color); + EditorGUI.DrawRect(GetLineRect(rect, thickness, padding, horizontal), color); } /// @@ -433,26 +452,41 @@ public static void DrawDefaultProperty(SerializedProperty property, GUIContent l return; } - var enterChildren = true; - //cache all needed property references - var targetProperty = property.Copy(); - var endingProperty = property.GetEndProperty(); - EditorGUI.indentLevel++; - //iterate over all children (but only 1 level depth) - while (targetProperty.NextVisible(enterChildren)) - { - if (SerializedProperty.EqualContents(targetProperty, endingProperty)) - { - break; - } + DrawPropertyChildren(property, drawElementAction); + EditorGUI.indentLevel--; + } + } + + /// + /// Draws property's children but only one level deep. + /// + public static void DrawPropertyChildren(SerializedProperty property) + { + DrawPropertyChildren(property, DrawToolboxProperty); + } - enterChildren = false; - //handle current property using Toolbox features - drawElementAction(targetProperty.Copy()); + /// + /// Draws property's children but only one level deep. + /// + public static void DrawPropertyChildren(SerializedProperty property, Action drawElementAction) + { + var enterChildren = true; + //cache all needed property references + var targetProperty = property.Copy(); + var endingProperty = property.GetEndProperty(); + //iterate over all children (but only 1 level depth) + while (targetProperty.NextVisible(enterChildren)) + { + if (SerializedProperty.EqualContents(targetProperty, endingProperty)) + { + break; } - EditorGUI.indentLevel--; + enterChildren = false; + var childProperty = targetProperty.Copy(); + //handle current property using Toolbox features + drawElementAction(childProperty); } } diff --git a/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs b/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs index 84853aec..bc6974d1 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs @@ -87,21 +87,21 @@ private static bool ValidateScopes() } - internal static void BeginVertical() + internal static Rect BeginVertical() { - BeginVertical(new GUIStyle()); + return BeginVertical(GUIStyle.none); } - internal static void BeginVertical(GUIStyle style, params GUILayoutOption[] options) + internal static Rect BeginVertical(GUIStyle style, params GUILayoutOption[] options) { if (!inEditorLayout) { ToolboxEditorLog.LogWarning("Begin vertical layout group action can be executed only within the Toolbox Editor."); - return; + return Rect.zero; } vLayoutClips++; - EditorGUILayout.BeginVertical(style, options); + return EditorGUILayout.BeginVertical(style, options); } internal static void CloseVertical() @@ -116,27 +116,27 @@ internal static void CloseVertical() EditorGUILayout.EndVertical(); } - internal static void BeginHorizontal() + internal static Rect BeginHorizontal() { - BeginHorizontal(new GUIStyle()); + return BeginHorizontal(GUIStyle.none); } - internal static void BeginHorizontal(GUIStyle style, params GUILayoutOption[] options) + internal static Rect BeginHorizontal(GUIStyle style, params GUILayoutOption[] options) { if (!inEditorLayout) { ToolboxEditorLog.LogWarning("Begin horizontal layout group action can be executed only within the Toolbox Editor."); - return; + return Rect.zero; } if (hLayoutClips > 0) { ToolboxEditorLog.LogWarning("Nested horizontal layout groups are not supported."); - return; + return Rect.zero; } hLayoutClips++; - EditorGUILayout.BeginHorizontal(style, options); + return EditorGUILayout.BeginHorizontal(style, options); } internal static void CloseHorizontal() diff --git a/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs b/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs index b4ad536d..f367de8d 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs @@ -268,12 +268,6 @@ private void DrawProperty(GUIContent label) } else { - if (hasToolboxPropertyDrawer) - { - //TODO: warning - //NOTE: since property has a custom drawer it will override any Toolbox-related one - } - OnGuiDefault(label); } } @@ -314,6 +308,19 @@ private PropertyCondition Validate() return ToolboxDrawerModule.GetConditionDrawer(conditionAttribute)?.OnGuiValidate(property, conditionAttribute) ?? PropertyCondition.Valid; } + /// + /// Begins vertical group to "pack" all property-related controls into one body. + /// + private void BeginVerticalLayoutBody() + { + EditorGUILayout.BeginVertical(); + } + + private void CloseVerticalLayoutBody() + { + EditorGUILayout.EndVertical(); + } + /// /// Draw property using built-in layout system and cached s. @@ -343,7 +350,9 @@ public void OnGuiLayout(GUIContent label) { using (new EditorGUI.DisabledScope(disable)) { + BeginVerticalLayoutBody(); DrawProperty(label); + CloseVerticalLayoutBody(); } } diff --git a/Assets/Editor Toolbox/EditorSettings.asset b/Assets/Editor Toolbox/EditorSettings.asset index 1f385381..0d1e0f7f 100644 --- a/Assets/Editor Toolbox/EditorSettings.asset +++ b/Assets/Editor Toolbox/EditorSettings.asset @@ -50,10 +50,12 @@ MonoBehaviour: decoratorDrawerHandlers: - classReference: Toolbox.Editor.Drawers.BeginGroupAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.BeginHorizontalAttributeDrawer, Toolbox-Editor + - classReference: Toolbox.Editor.Drawers.BeginHorizontalGroupAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.BeginIndentAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.EditorButtonAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.EndGroupAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.EndHorizontalAttributeDrawer, Toolbox-Editor + - classReference: Toolbox.Editor.Drawers.EndHorizontalGroupAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.EndIndentAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.HelpAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.HighlightAttributeDrawer, Toolbox-Editor diff --git a/Assets/Editor Toolbox/README.md b/Assets/Editor Toolbox/README.md index 72c5f67b..190c5fe6 100644 --- a/Assets/Editor Toolbox/README.md +++ b/Assets/Editor Toolbox/README.md @@ -268,11 +268,18 @@ public int var3; public int var4; ``` ```csharp -[BeginHorizontal] +[BeginHorizontal(labelToWidthRatio: 0.1f)] public int var1; public int var2; [EndHorizontal] public int var3; + +[BeginHorizontalGroup(label: "Horizontal Group")] +public GameObject gameObject; +[SpaceArea] +[EndHorizontalGroup] +[ReorderableList] +public int[] ints; ``` ```csharp [BeginIndent] @@ -316,6 +323,8 @@ public int var1; ``` ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/decorators.png) +![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/horizontal.png) + ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/imagearea.png) ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/helpbox.png) diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalAttribute.cs index 54ef6727..c8848d9e 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalAttribute.cs @@ -8,7 +8,7 @@ namespace UnityEngine [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class BeginHorizontalAttribute : ToolboxDecoratorAttribute { - public BeginHorizontalAttribute(float labelToWidthRatio = 0.1f, float fieldToWidthRatio = 0.0f) + public BeginHorizontalAttribute(float labelToWidthRatio = 0.0f, float fieldToWidthRatio = 0.0f) { LabelToWidthRatio = labelToWidthRatio; FieldToWidthRatio = fieldToWidthRatio; diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalGroupAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalGroupAttribute.cs new file mode 100644 index 00000000..304a1214 --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalGroupAttribute.cs @@ -0,0 +1,31 @@ +using System; + +namespace UnityEngine +{ + /// + /// Begins horizontal group of properties. + /// Additionally, creates title label and scrollbar if needed. + /// Has to be closed by the . + /// + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + public class BeginHorizontalGroupAttribute : BeginHorizontalAttribute + { + public BeginHorizontalGroupAttribute(float labelToWidthRatio = 0.0f, float fieldToWidthRatio = 0.0f, string label = null) : base(labelToWidthRatio, fieldToWidthRatio) + { + Label = label; + } + + public string Label { get; private set; } + + public bool HasLabel => !string.IsNullOrEmpty(Label); + +#if UNITY_2019_1_OR_NEWER + /// + /// Indicates the fixed height of the horizontal group, if is equal to 0 then height will be auto-sized. + /// + public float Height { get; set; } = 0.0f; +#else + public float Height { get; set; } = 300.0f; +#endif + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalGroupAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalGroupAttribute.cs.meta new file mode 100644 index 00000000..8dc8355e --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/BeginHorizontalGroupAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db26257335296c8439ea9e58be7b328e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/EndHorizontalGroupAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/EndHorizontalGroupAttribute.cs new file mode 100644 index 00000000..633e4ee8 --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/EndHorizontalGroupAttribute.cs @@ -0,0 +1,8 @@ +using System; + +namespace UnityEngine +{ + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + public class EndHorizontalGroupAttribute : EndHorizontalAttribute + { } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/EndHorizontalGroupAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/EndHorizontalGroupAttribute.cs.meta new file mode 100644 index 00000000..81fe93a6 --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/EndHorizontalGroupAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a30c3ba3b053ad943965a580f72f6419 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LineAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LineAttribute.cs index f8ac48fc..033a9032 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LineAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LineAttribute.cs @@ -12,12 +12,18 @@ public LineAttribute(float thickness = 0.75f, float padding = 6.0f) { Thickness = Math.Max(thickness, 0); Padding = padding; + IsHorizontal = true; } public float Thickness { get; private set; } public float Padding { get; private set; } + /// + /// Indicates if the line should be horizontal, otherwise will be drawn vertically. + /// + public bool IsHorizontal { get; set; } + /// /// Indicates if drawer should apply additional indent to the line's width. /// @@ -33,17 +39,9 @@ public LineAttribute(float thickness = 0.75f, float padding = 6.0f) /// public Color GuiColor { - get - { - if (ColorUtility.TryParseHtmlString(HexColor, out var color)) - { - return color; - } - else - { - return new Color(0.3f, 0.3f, 0.3f); - } - } + get => ColorUtility.TryParseHtmlString(HexColor, out var color) + ? color + : new Color(0.3f, 0.3f, 0.3f); } } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/package.json b/Assets/Editor Toolbox/package.json index 754f6d8c..114ca648 100644 --- a/Assets/Editor Toolbox/package.json +++ b/Assets/Editor Toolbox/package.json @@ -1,7 +1,7 @@ { "name": "com.arimger.editor-toolbox", "displayName": "Editor Toolbox", - "version": "0.8.11", + "version": "0.8.13", "unity": "2018.1", "description": "Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.", "keywords": [ diff --git a/Assets/Examples/Scenes/SampleScene.unity b/Assets/Examples/Scenes/SampleScene.unity index bdf38f96..d9192f71 100644 --- a/Assets/Examples/Scenes/SampleScene.unity +++ b/Assets/Examples/Scenes/SampleScene.unity @@ -99,7 +99,7 @@ LightmapSettings: m_LightProbeSampleCountMultiplier: 4 m_LightingDataAsset: {fileID: 112000000, guid: 4f45668bfc38b4c4bb6229eef4382cbb, type: 2} - m_LightingSettings: {fileID: 4890085278179872738, guid: ccb01454973bb9a40bf3814633c8db30, + m_LightingSettings: {fileID: 4890085278179872738, guid: 8aebe3ea7163bc84194ae1d81c850abb, type: 2} --- !u!196 &4 NavMeshSettings: @@ -487,15 +487,23 @@ MonoBehaviour: - {fileID: 0} var36: 1 dictionary: - pairs: - - key: 5 - value: {fileID: 977748987} - - key: 2 - value: {fileID: 534669902} - - key: 3 - value: {fileID: 2037155952} + pairs: [] error: 0 - ints: + ints: 01000000080000000c00000010000000 + q: {x: 0, y: 0, z: 0, w: 0} + gameObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 5059060190599569098, guid: 5573ca52cac7c2d4cb2536e37e9be1f1, type: 3} + - {fileID: 0} + floats: + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 + - 0 --- !u!4 &661896459 Transform: m_ObjectHideFlags: 2 @@ -630,10 +638,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c96bc1945c12e5246b1faac636a63516, type: 3} m_Name: m_EditorClassIdentifier: - aa: - classReference: - aaa: - classReference: UnityEngine.AvatarMask, UnityEngine.AnimationModule var1: 82 targetTag: Untagged progressBar: 25.4 diff --git a/Assets/Examples/Scripts/SampleBehaviour2.cs b/Assets/Examples/Scripts/SampleBehaviour2.cs index 519a5a95..bcbe00d9 100644 --- a/Assets/Examples/Scripts/SampleBehaviour2.cs +++ b/Assets/Examples/Scripts/SampleBehaviour2.cs @@ -107,7 +107,7 @@ public class SampleNestedClass [Label("7", skinStyle: SkinStyle.Box)] - [BeginHorizontal] + [BeginHorizontal(labelToWidthRatio: 0.1f)] public int var29; public int var30; //NOTE: custom sample created within the Examples @@ -158,4 +158,19 @@ public int GetValue() { return ints.Length * Random.Range(1, 5); } + + [Label("14", skinStyle: SkinStyle.Box)] + + [IgnoreParent] + public Quaternion q; + + [Label("15", skinStyle: SkinStyle.Box)] + + [BeginHorizontalGroup(label: "Horizontal Group")] + [ReorderableList, InLineEditor] + public GameObject[] gameObjects; + [SpaceArea] + [EndHorizontalGroup] + [ReorderableList] + public float[] floats; } \ No newline at end of file diff --git a/Docs/horizontal.png b/Docs/horizontal.png new file mode 100644 index 00000000..dea8e927 Binary files /dev/null and b/Docs/horizontal.png differ diff --git a/README.md b/README.md index 72c5f67b..190c5fe6 100644 --- a/README.md +++ b/README.md @@ -268,11 +268,18 @@ public int var3; public int var4; ``` ```csharp -[BeginHorizontal] +[BeginHorizontal(labelToWidthRatio: 0.1f)] public int var1; public int var2; [EndHorizontal] public int var3; + +[BeginHorizontalGroup(label: "Horizontal Group")] +public GameObject gameObject; +[SpaceArea] +[EndHorizontalGroup] +[ReorderableList] +public int[] ints; ``` ```csharp [BeginIndent] @@ -316,6 +323,8 @@ public int var1; ``` ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/decorators.png) +![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/horizontal.png) + ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/imagearea.png) ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/helpbox.png)