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 #125 from techno-dwarf-works/feature/refactoring
Browse files Browse the repository at this point in the history
Version 3.1.5
  • Loading branch information
uurha committed Jul 12, 2024
1 parent 8b5e964 commit 9ff5931
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
namespace Better.Attributes.EditorAddons.CustomEditors
{
[MultiEditor(typeof(Object), true, Order = 999)]
public class BetterButtonsEditor : ExtendedEditor
public class ButtonsEditor : ExtendedEditor
{
private Dictionary<int, IEnumerable<KeyValuePair<MethodInfo, EditorButtonAttribute>>> _methodButtonsAttributes =
new Dictionary<int, IEnumerable<KeyValuePair<MethodInfo, EditorButtonAttribute>>>();

public BetterButtonsEditor(Object target, SerializedObject serializedObject) : base(target, serializedObject)
public ButtonsEditor(Object target, SerializedObject serializedObject) : base(target, serializedObject)
{
}

Expand All @@ -38,8 +38,10 @@ private Button DrawButton(MethodInfo methodInfo, EditorButtonAttribute attribute
{
var button = new Button
{
text = attribute.GetDisplayName(methodInfo.PrettyMemberName())
text = attribute.GetDisplayName(methodInfo.PrettyMemberName()),
name = methodInfo.PrettyMemberName()
};
button.style.FlexGrow(StyleDefinition.OneStyleFloat);
button.RegisterCallback<ClickEvent, (MethodInfo, EditorButtonAttribute)>(OnClick, (methodInfo, attribute));
return button;
}
Expand All @@ -64,6 +66,7 @@ private VisualElement DrawButtons(Dictionary<int, IEnumerable<KeyValuePair<Metho
var grouped = button.Value.GroupBy(key => key.Key, pair => pair.Value,
(info, attributes) => new KeyValuePair<MethodInfo, IEnumerable<EditorButtonAttribute>>(info, attributes));
var verticalElement = VisualElementUtility.CreateVerticalGroup();
container.Add(verticalElement);

foreach (var group in grouped)
{
Expand All @@ -80,6 +83,7 @@ private VisualElement DrawButtons(Dictionary<int, IEnumerable<KeyValuePair<Metho
else
{
var horizontalElement = VisualElementUtility.CreateHorizontalGroup();
container.Add(horizontalElement);
foreach (var (key, value) in button.Value)
{
var element = DrawButton(key, value);
Expand Down
6 changes: 5 additions & 1 deletion Editor/EditorAddons/Drawers/Gizmo/HideTransformDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using UnityEditor;
using Better.Commons.EditorAddons.Utility;
using Better.Commons.Runtime.Extensions;
using UnityEditor;
using UnityEngine.UIElements;

namespace Better.Attributes.EditorAddons.Drawers.Gizmo
Expand All @@ -8,8 +10,10 @@ public class HideTransformButtonHelper
public VisualElement DrawHideTransformButton()
{
var button = new Button();
button.name = nameof(HideTransformButtonHelper);
UpdateButtonText(button);
UpdateButtonText(button);
button.style.FlexGrow(StyleDefinition.OneStyleFloat);
button.RegisterCallback<ClickEvent, Button>(OnClicked, button);
return button;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.uurha.betterattributes",
"displayName": "Better Attributes",
"version": "3.1.4",
"version": "3.1.5",
"unity": "2021.3",
"description": "Unity attributes, allows to serialize interfaces, draw handles for Vector3/Vector2/Quaternion/Bounds, create read only fields.",
"dependencies": {
Expand Down

0 comments on commit 9ff5931

Please sign in to comment.