Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #115 from techno-dwarf-works/feature/editor-buttons
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
uurha committed Apr 10, 2024
1 parent 66f0f1f commit edacd97
Show file tree
Hide file tree
Showing 81 changed files with 300 additions and 364 deletions.
7 changes: 2 additions & 5 deletions Editor/BetterAttributes.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
"rootNamespace": "Better.Attributes.EditorAddons",
"references": [
"GUID:35101f455c979e94c9a0a4793484b7fd",
"GUID:28da8d3b12e3efa47928e0c9070f853d",
"GUID:19891d5296046644cbc12fcf3702cca3",
"GUID:443314a5a4e67c14a88ae223776b6554",
"GUID:a59e3daedde9ca94bba45364d4ead25f",
"GUID:01df13aca8d01e24a911bcc3e8277031",
"GUID:1ac867a6259e45a1856740fe8f7623aa"
"GUID:8bd4b41f8da90144d9006c4d926c9679",
"GUID:55fbe2a01ca11514f94a66e7102c8895"
],
"includePlatforms": [
"Editor"
Expand Down
3 changes: 3 additions & 0 deletions Editor/EditorAddons/Comparers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using Better.EditorTools.EditorAddons.Comparers;
using Better.Commons.Runtime.Comparers;

namespace Better.Attributes.EditorAddons.Drawers.Utilities
namespace Better.Attributes.EditorAddons.Comparers
{
public class AnyTypeComparer : BaseComparer<AnyTypeComparer,Type>, IEqualityComparer<Type>
{
Expand Down
19 changes: 15 additions & 4 deletions Editor/EditorAddons/CustomEditors/BetterButtonsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
using System.Linq;
using System.Reflection;
using Better.Attributes.Runtime;
using Better.EditorTools.EditorAddons.CustomEditors;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.CustomEditors.Attributes;
using Better.Commons.EditorAddons.CustomEditors.Base;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;

namespace Better.Attributes.EditorAddons.CustomEditors
{
[MultiEditor(typeof(Object), true, Order = 999)]
public class BetterButtonsEditor : EditorExtension
public class BetterButtonsEditor : ExtendedEditor
{
private Dictionary<int, IEnumerable<KeyValuePair<MethodInfo, EditorButtonAttribute>>> _methodButtonsAttributes =
new Dictionary<int, IEnumerable<KeyValuePair<MethodInfo, EditorButtonAttribute>>>();
Expand All @@ -36,7 +37,17 @@ private void DrawButton(KeyValuePair<MethodInfo, EditorButtonAttribute> button,
var methodInfo = button.Key;

if (GUILayout.Button(attribute.GetDisplayName(methodInfo.PrettyMemberName()), guiStyle))
methodInfo.Invoke(_target, attribute.InvokeParams);
{
using (var changeScope = new EditorGUI.ChangeCheckScope())
{
methodInfo.Invoke(_target, attribute.InvokeParams);
if (changeScope.changed)
{
EditorUtility.SetDirty(_target);
_serializedObject.ApplyModifiedProperties();
}
}
}
}

private void DrawButtons(Dictionary<int, IEnumerable<KeyValuePair<MethodInfo, EditorButtonAttribute>>> buttons)
Expand Down
7 changes: 4 additions & 3 deletions Editor/EditorAddons/CustomEditors/GizmosEditor.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System.Reflection;
using Better.Attributes.EditorAddons.Drawers.Gizmo;
using Better.Attributes.Runtime.Gizmo;
using Better.EditorTools.EditorAddons.CustomEditors;
using Better.Extensions.EditorAddons;
using Better.Commons.EditorAddons.CustomEditors.Attributes;
using Better.Commons.EditorAddons.CustomEditors.Base;
using Better.Commons.EditorAddons.Extensions;
using UnityEditor;
using UnityEngine;

namespace Better.Attributes.EditorAddons.CustomEditors
{
[MultiEditor(typeof(Object), true, Order = -999)]
public class GizmosEditor : EditorExtension
public class GizmosEditor : ExtendedEditor
{
private HideTransformButtonUtility _hideTransformDrawer;

Expand Down
21 changes: 12 additions & 9 deletions Editor/EditorAddons/Drawers/DrawInspector/DrawInspectorDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System.Reflection;
using Better.Attributes.EditorAddons.Drawers.Utilities;
using Better.Attributes.EditorAddons.Drawers.Utility;
using Better.Attributes.EditorAddons.Drawers.WrapperCollections;
using Better.Attributes.Runtime.DrawInspector;
using Better.EditorTools.EditorAddons.Attributes;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.EditorAddons.Helpers;
using Better.EditorTools.Runtime.Attributes;
using Better.Commons.EditorAddons.Drawers.Attributes;
using Better.Commons.EditorAddons.Drawers.Base;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Enums;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.EditorAddons.Utility;
using Better.Commons.Runtime.Drawers.Attributes;
using UnityEditor;
using UnityEngine;

Expand All @@ -29,7 +32,7 @@ protected override bool PreDraw(ref Rect position, SerializedProperty property,
{
EditorGUI.BeginChangeCheck();
DrawField(position, property, label);
DrawersHelper.NotSupportedAttribute(position, property, label, fieldType, _attribute.GetType());
ExtendedGUIUtility.NotSupportedAttribute(position, property, label, fieldType, _attribute.GetType());
return false;
}

Expand All @@ -42,12 +45,12 @@ protected override bool PreDraw(ref Rect position, SerializedProperty property,
_isOpen = Collection.IsOpen(property);
if (property.objectReferenceValue)
{
label.image = DrawersHelper.GetIcon(_isOpen ? IconType.Minus : IconType.PlusMore);
label.image = (_isOpen ? IconType.Minus : IconType.PlusMore).GetIcon();
}

var copy = DrawersHelper.GetClickRect(position, label);
var copy = ExtendedGUIUtility.GetClickRect(position, label);
copy.height = EditorGUIUtility.singleLineHeight;
if (DrawersHelper.IsClickedAt(copy))
if (ExtendedGUIUtility.IsClickedAt(copy))
{
Collection.SetOpen(property, !_isOpen);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Better.EditorTools.EditorAddons.Helpers;
using Better.EditorTools.EditorAddons.Utilities;
using Better.Commons.EditorAddons.Drawers.Utility;
using Better.Commons.EditorAddons.Utility;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -51,7 +51,7 @@ public void PostDraw(Rect rect)
public void SetOpen(bool value)
{
_isOpen = value;
ReorderableListHelpers.RepaintAllInspectors(_property);
ReorderableListUtility.RepaintAllInspectors(_property);
}

public bool IsOpen()
Expand Down
10 changes: 5 additions & 5 deletions Editor/EditorAddons/Drawers/Gizmo/BaseWrappers/GizmoWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Better.Attributes.EditorAddons.Drawers.Utilities;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.EditorAddons.Utilities;
using Better.Extensions.EditorAddons;
using Better.Extensions.Runtime;
using Better.Attributes.EditorAddons.Drawers.Utility;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Drawers.Utility;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.Runtime.Utility;
using UnityEditor;
using UnityEngine;
#if UNITY_2022_1_OR_NEWER
Expand Down
25 changes: 13 additions & 12 deletions Editor/EditorAddons/Drawers/Gizmo/GizmoDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System.Reflection;
using Better.Attributes.EditorAddons.Drawers.WrapperCollections;
using Better.Attributes.Runtime.Gizmo;
using Better.EditorTools.EditorAddons.Attributes;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.EditorAddons.Helpers;
using Better.EditorTools.Runtime.Attributes;
using Better.Commons.EditorAddons.Drawers.Attributes;
using Better.Commons.EditorAddons.Drawers.Base;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Enums;
using Better.Commons.EditorAddons.Utility;
using Better.Commons.Runtime.Drawers.Attributes;
using UnityEditor;
using UnityEngine;

#if UNITY_2022_1_OR_NEWER
using GizmoUtility = Better.Attributes.EditorAddons.Drawers.Utilities.GizmoUtility;

using GizmoUtility = Better.Attributes.EditorAddons.Drawers.Utility.GizmoUtility;
#else
using Better.Attributes.EditorAddons.Drawers.Utilities;
using Better.Attributes.EditorAddons.Drawers.Utility;
#endif

namespace Better.Attributes.EditorAddons.Drawers.Gizmo
Expand Down Expand Up @@ -80,7 +81,7 @@ protected override bool PreDraw(ref Rect position, SerializedProperty property,
if (!GizmoUtility.Instance.IsSupported(fieldType))
{
var rect = new Rect(position);
DrawersHelper.NotSupportedAttribute(rect, property, label, fieldType, attributeType);
ExtendedGUIUtility.NotSupportedAttribute(rect, property, label, fieldType, attributeType);
return true;
}

Expand Down Expand Up @@ -140,7 +141,7 @@ protected override Rect PreparePropertyRect(Rect original)
private Rect PrepareButtonRect(Rect original)
{
var copy = original;
copy.x += copy.width + DrawersHelper.SpaceHeight;
copy.x += copy.width + ExtendedGUIUtility.SpaceHeight;
copy.width *= 0.1f;
copy.height = EditorGUIUtility.singleLineHeight;
return copy;
Expand All @@ -151,9 +152,9 @@ protected override HeightCacheValue GetPropertyHeight(SerializedProperty propert
var fieldType = GetFieldOrElementType();
if (!GizmoUtility.Instance.IsSupported(fieldType))
{
var message = DrawersHelper.NotSupportedMessage(property.name, fieldType, _attribute.GetType());
var additive = DrawersHelper.GetHelpBoxHeight(EditorGUIUtility.currentViewWidth, message, IconType.WarningMessage);
return HeightCacheValue.GetAdditive(additive + DrawersHelper.SpaceHeight * 2);
var message = ExtendedGUIUtility.NotSupportedMessage(property.name, fieldType, _attribute.GetType());
var additive = ExtendedGUIUtility.GetHelpBoxHeight(EditorGUIUtility.currentViewWidth, message, IconType.WarningMessage);
return HeightCacheValue.GetAdditive(additive + ExtendedGUIUtility.SpaceHeight * 2);
}

return Collection.GetHeight(property, label);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Better.Extensions.EditorAddons;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.Runtime.Utility;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.Extensions.EditorAddons;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Better.Extensions.EditorAddons;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Better.Extensions.EditorAddons;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Extensions;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Better.Extensions.Runtime;
using Better.Commons.Runtime.Extensions;
using UnityEditor;

namespace Better.Attributes.EditorAddons.Drawers.Gizmo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Better.Extensions.Runtime;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Better.Extensions.Runtime;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine;

Expand Down
9 changes: 5 additions & 4 deletions Editor/EditorAddons/Drawers/Manipulation/ManipulateDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Reflection;
using Better.Attributes.EditorAddons.Drawers.Manipulation.Wrappers;
using Better.Attributes.EditorAddons.Drawers.Utilities;
using Better.Attributes.EditorAddons.Drawers.Utility;
using Better.Attributes.Runtime.Manipulation;
using Better.EditorTools.EditorAddons.Attributes;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.Runtime.Attributes;
using Better.Commons.EditorAddons.Drawers.Attributes;
using Better.Commons.EditorAddons.Drawers.Base;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.Runtime.Drawers.Attributes;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Better.Attributes.Runtime.Manipulation;
using Better.Extensions.EditorAddons;
using Better.Commons.EditorAddons.Extensions;
using Better.Internal.Core.Runtime;
using UnityEditor;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Better.Attributes.Runtime.Manipulation;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.EditorAddons.Helpers;
using Better.EditorTools.EditorAddons.Utilities;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Drawers.Utility;
using Better.Commons.EditorAddons.Utility;
using Better.Commons.Runtime.Utility;
using UnityEditor;
using UnityEngine;

Expand Down
9 changes: 5 additions & 4 deletions Editor/EditorAddons/Drawers/Misc/MiscDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Reflection;
using Better.Attributes.EditorAddons.Drawers.Misc.Wrappers;
using Better.Attributes.EditorAddons.Drawers.Utilities;
using Better.Attributes.EditorAddons.Drawers.Utility;
using Better.Attributes.Runtime.Misc;
using Better.EditorTools.EditorAddons.Attributes;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.Runtime.Attributes;
using Better.Commons.EditorAddons.Drawers.Attributes;
using Better.Commons.EditorAddons.Drawers.Base;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.Runtime.Drawers.Attributes;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Reflection;
using Better.Attributes.Runtime.Misc;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.Commons.EditorAddons.Drawers.Caching;
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
using System.Reflection;
using Better.Attributes.EditorAddons.Extensions;
using Better.Attributes.Runtime.Misc;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.EditorAddons.Helpers;
using Better.Extensions.Runtime;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Helpers;
using Better.Commons.Runtime.Extensions;
using Better.Commons.Runtime.Utility;
using UnityEditor;
using UnityEngine;

Expand Down
8 changes: 4 additions & 4 deletions Editor/EditorAddons/Drawers/Misc/Wrappers/HelpBoxWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;
using Better.Attributes.Runtime.Misc;
using Better.EditorTools.EditorAddons.Drawers.Base;
using Better.EditorTools.EditorAddons.Helpers;
using Better.Commons.EditorAddons.Drawers.Caching;
using Better.Commons.EditorAddons.Utility;
using UnityEditor;
using UnityEngine;

Expand All @@ -27,7 +27,7 @@ public override void PreDraw(Rect position, GUIContent label)
copy.height = _helpBoxHeight;
copy.y += _propertyHeight + EditorGUIUtility.standardVerticalSpacing;

DrawersHelper.HelpBox(copy, _helpBoxContent);
ExtendedGUIUtility.HelpBox(copy, _helpBoxContent);
}

public override void DrawField(Rect rect, GUIContent label)
Expand All @@ -42,7 +42,7 @@ public override void PostDraw()
public override HeightCacheValue GetHeight(GUIContent label)
{
_propertyHeight = EditorGUI.GetPropertyHeight(_property, label);
_helpBoxHeight = DrawersHelper.GetHelpBoxHeight(_helpBoxContent);
_helpBoxHeight = ExtendedGUIUtility.GetHelpBoxHeight(_helpBoxContent);
return HeightCacheValue.GetFull(_propertyHeight + _helpBoxHeight + EditorGUIUtility.standardVerticalSpacing);
}
}
Expand Down
Loading

0 comments on commit edacd97

Please sign in to comment.