Skip to content

Commit ce91498

Browse files
authored
Merge pull request #127 from arimger/develop
Develop - 0.14.0
2 parents a07a3e9 + 7e850c5 commit ce91498

36 files changed

+313
-99
lines changed

.github/workflows/activation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
uses: game-ci/unity-request-activation-file@v2
1313
# Upload artifact (Unity_v20XX.X.XXXX.alf)
1414
- name: Expose as artifact
15-
uses: actions/upload-artifact@v2
15+
uses: actions/upload-artifact@v4
1616
with:
1717
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
1818
path: ${{ steps.getManualLicenseFile.outputs.filePath }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
testMode: ${{ matrix.testMode }}
3838
artifactsPath: ${{ matrix.testMode }}-artifacts
3939
checkName: ${{ matrix.testMode }} Test Results
40-
- uses: actions/upload-artifact@v3
40+
- uses: actions/upload-artifact@v4
4141
if: always()
4242
with:
4343
name: Test results for ${{ matrix.testMode }}

.github/workflows/upm-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: split upm branch
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414
- name: split upm branch

.github/workflows/upm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: split upm branch
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414
- name: split upm branch

Assets/Editor Toolbox/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 0.14.0 [23.02.2025]
2+
3+
### Added:
4+
- OnToolbarGuiRight callback (ability to draw GUI elements on the right side of the toolbar container); OnToolbarGui replaced with the OnToolbarGuiLeft callback
5+
6+
### Changed:
7+
- Fix fetching private members from base classes in various cases (e.g. [EditorButton] or conditionals)
8+
- Move FolderData to the Runtime assembly to fix issues caused by the Visual Scripting package
9+
- Fix minor rendering issues caused by the ReoerdableList's footer position
10+
- Fix clearing cached Editor instances in the [InLineEditor] (fix for the AudioClip still playing)
11+
- Improve displaying [SerializeReference]-based properties in the multi-editing mode
12+
113
## 0.13.2 [29.11.2024]
214

315
### Added:

Assets/Editor Toolbox/Editor/Drawers/Helpers/Extraction/FieldValueExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public bool TryGetValue(string source, object declaringObject, out object value)
1111
}
1212

1313
var type = declaringObject.GetType();
14-
var info = type.GetField(source, ReflectionUtility.allBindings);
14+
var info = ReflectionUtility.GetField(type, source);
1515
if (info == null)
1616
{
1717
return false;

Assets/Editor Toolbox/Editor/Drawers/Helpers/Extraction/MethodValueExtractor.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Reflection;
3-
4-
namespace Toolbox.Editor.Drawers
1+
namespace Toolbox.Editor.Drawers
52
{
63
public class MethodValueExtractor : IValueExtractor
74
{
@@ -14,7 +11,7 @@ public bool TryGetValue(string source, object declaringObject, out object value)
1411
}
1512

1613
var type = declaringObject.GetType();
17-
var info = type.GetMethod(source, ReflectionUtility.allBindings, null, CallingConventions.Any, new Type[0], null);
14+
var info = ReflectionUtility.GetMethod(type, source);
1815
if (info == null)
1916
{
2017
return false;

Assets/Editor Toolbox/Editor/Drawers/Helpers/Extraction/PropertyValueExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public bool TryGetValue(string source, object declaringObject, out object value)
1111
}
1212

1313
var type = declaringObject.GetType();
14-
var info = type.GetProperty(source, ReflectionUtility.allBindings);
14+
var info = ReflectionUtility.GetProperty(type, source);
1515
if (info == null)
1616
{
1717
return false;

Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Toolbox.Editor.Drawers
55
{
6-
using Toolbox.Editor.Folders;
6+
using Toolbox.Folders;
77

88
[CustomPropertyDrawer(typeof(FolderData))]
99
internal class FolderDataDrawer : PropertyDrawer

Assets/Editor Toolbox/Editor/Drawers/Toolbox/Decorator/EditorButtonAttributeDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class EditorButtonAttributeDrawer : ToolboxDecoratorDrawer<EditorButtonAt
1010
{
1111
private MethodInfo GetMethod(EditorButtonAttribute attribute, object[] targetObjects, string methodName)
1212
{
13-
var methodInfo = ReflectionUtility.GetObjectMethod(methodName, targetObjects);
13+
var methodInfo = ReflectionUtility.GetMethod(methodName, targetObjects);
1414
if (methodInfo == null)
1515
{
1616
ToolboxEditorLog.AttributeUsageWarning(attribute, string.Format("{0} method not found.", methodName));

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertyList/ReorderableListExposedAttributeDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static MethodInfo FindMethod(SerializedObject target, string methodName,
5656
return null;
5757
}
5858

59-
var methodInfo = ReflectionUtility.GetObjectMethod(methodName, target);
59+
var methodInfo = ReflectionUtility.GetMethod(methodName, target);
6060
if (methodInfo == null)
6161
{
6262
ToolboxEditorLog.AttributeUsageWarning(typeof(ReorderableListExposedAttribute), string.Format("{0} method not found.", methodName));

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/InLineEditorAttributeDrawer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ static InLineEditorAttributeDrawer()
4646

4747
private static readonly PropertyDataStorage<Editor, InLineEditorAttribute> storage;
4848

49-
5049
private Editor GetTargetsEditor(SerializedProperty property, InLineEditorAttribute attribute)
5150
{
5251
var editor = storage.ReturnItem(property, attribute);
@@ -108,7 +107,6 @@ private void DrawEditor(Editor editor, bool disableEditor, bool drawPreview, boo
108107
}
109108
}
110109

111-
112110
/// <summary>
113111
/// Handles the property drawing process and tries to create a inlined version of the <see cref="Editor"/>.
114112
/// </summary>
@@ -151,15 +149,17 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
151149
DrawEditor(editor, attribute);
152150
}
153151
}
152+
else
153+
{
154+
storage.ClearItem(property);
155+
}
154156
}
155157

156-
157158
public override bool IsPropertyValid(SerializedProperty property)
158159
{
159160
return property.propertyType == SerializedPropertyType.ObjectReference;
160161
}
161162

162-
163163
private static class Style
164164
{
165165
internal static readonly GUIStyle backgroundStyle;

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,38 @@ private Type GetParentType(ReferencePickerAttribute attribute, SerializedPropert
4141
return fieldType;
4242
}
4343

44+
private static Type GetCurrentManagedReferenceType(SerializedProperty property, out bool hasMixedValues)
45+
{
46+
var fullTypeName = property.managedReferenceFullTypename;
47+
hasMixedValues = false;
48+
TypeUtility.TryGetTypeFromManagedReferenceFullTypeName(fullTypeName, out var targetType);
49+
50+
var currentSerializedObject = property.serializedObject;
51+
if (currentSerializedObject.isEditingMultipleObjects)
52+
{
53+
var targets = currentSerializedObject.targetObjects;
54+
foreach (var target in targets)
55+
{
56+
using (var tempSerializedObject = new SerializedObject(target))
57+
{
58+
var tempProperty = tempSerializedObject.FindProperty(property.propertyPath);
59+
if (tempProperty.managedReferenceFullTypename != fullTypeName)
60+
{
61+
hasMixedValues = true;
62+
break;
63+
}
64+
}
65+
}
66+
}
67+
68+
return targetType;
69+
}
70+
4471
private void CreateTypeProperty(SerializedProperty property, Type parentType, ReferencePickerAttribute attribute, Rect position)
4572
{
46-
TypeUtility.TryGetTypeFromManagedReferenceFullTypeName(property.managedReferenceFullTypename, out var currentType);
73+
var currentType = GetCurrentManagedReferenceType(property, out var hasMixedValues);
74+
var hadMixedValues = EditorGUI.showMixedValue;
75+
EditorGUI.showMixedValue = hasMixedValues;
4776
typeField.OnGui(position, attribute.AddTextSearchField, (type) =>
4877
{
4978
try
@@ -70,6 +99,7 @@ private void CreateTypeProperty(SerializedProperty property, Type parentType, Re
7099
ToolboxEditorLog.LogWarning("Invalid attempt to update disposed property.");
71100
}
72101
}, currentType, parentType);
102+
EditorGUI.showMixedValue = false;
73103
}
74104

75105
private void UpdateTypeProperty(SerializedProperty property, Type targetType, ReferencePickerAttribute attribute)

Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ protected virtual bool DoListFooter(Rect footerRect)
334334
return false;
335335
}
336336

337+
footerRect.yMax += Style.footerXOffset;
338+
footerRect.yMin += Style.footerYOffset;
337339
//draw the background on repaint event
338340
if (Event.current.type == EventType.Repaint)
339341
{
@@ -870,6 +872,8 @@ protected static class Style
870872
#else
871873
internal static readonly float lineHeight = 16.0f;
872874
#endif
875+
internal static readonly float footerXOffset = 0.0f;
876+
internal static readonly float footerYOffset = -1.0f;
873877
internal static readonly float footerWidth = 60.0f;
874878
internal static readonly float footerButtonWidth = 25.0f;
875879
internal static readonly float footerButtonHeight = 13.0f;

Assets/Editor Toolbox/Editor/ToolboxEditorProject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Toolbox.Editor
77
{
8-
using Toolbox.Editor.Folders;
8+
using Toolbox.Folders;
99

1010
/// <summary>
1111
/// Static GUI representation for the Project Overlay.

Assets/Editor Toolbox/Editor/ToolboxEditorSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
namespace Toolbox.Editor
77
{
88
using Toolbox.Editor.Drawers;
9-
using Toolbox.Editor.Folders;
109
using Toolbox.Editor.Hierarchy;
10+
using Toolbox.Folders;
1111

1212
internal interface IToolboxGeneralSettings
1313
{ }

Assets/Editor Toolbox/Editor/ToolboxEditorToolbar.cs

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static ToolboxEditorToolbar()
5353

5454
private static IEnumerator Initialize()
5555
{
56-
while (ToolboxEditorToolbar.toolbar == null)
56+
while (toolbar == null)
5757
{
5858
var toolbars = Resources.FindObjectsOfTypeAll(toolbarType);
5959
if (toolbars == null || toolbars.Length == 0)
@@ -63,15 +63,15 @@ private static IEnumerator Initialize()
6363
}
6464
else
6565
{
66-
ToolboxEditorToolbar.toolbar = toolbars[0];
66+
toolbar = toolbars[0];
6767
}
6868
}
6969

7070
#if UNITY_2021_1_OR_NEWER
71-
var rootField = ToolboxEditorToolbar.toolbar.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
72-
var root = rootField.GetValue(ToolboxEditorToolbar.toolbar) as VisualElement;
73-
var toolbar = root.Q("ToolbarZoneLeftAlign");
71+
var rootField = toolbar.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
72+
var root = rootField.GetValue(toolbar) as VisualElement;
7473

74+
var toolbarLeftZone = root.Q("ToolbarZoneLeftAlign");
7575
var element = new VisualElement()
7676
{
7777
style =
@@ -83,10 +83,25 @@ private static IEnumerator Initialize()
8383

8484
var container = new IMGUIContainer();
8585
container.style.flexGrow = 1;
86-
container.onGUIHandler += OnGui;
87-
86+
container.onGUIHandler += OnGuiLeft;
8887
element.Add(container);
89-
toolbar.Add(element);
88+
toolbarLeftZone.Add(element);
89+
90+
var toolbarRightZone = root.Q("ToolbarZoneRightAlign");
91+
var rightElement = new VisualElement()
92+
{
93+
style =
94+
{
95+
flexGrow = 1,
96+
flexDirection = FlexDirection.Row,
97+
}
98+
};
99+
100+
var rightContainer = new IMGUIContainer();
101+
rightContainer.style.flexGrow = 1;
102+
rightContainer.onGUIHandler += OnGuiRight;
103+
rightElement.Add(rightContainer);
104+
toolbarRightZone.Add(rightElement);
90105
#else
91106
#if UNITY_2020_1_OR_NEWER
92107
var backend = guiBackend.GetValue(toolbar);
@@ -101,23 +116,23 @@ private static IEnumerator Initialize()
101116
var container = elements[0] as IMGUIContainer;
102117
#endif
103118
var handler = onGuiHandler.GetValue(container) as Action;
104-
handler -= OnGui;
105-
handler += OnGui;
119+
handler -= OnGuiLeft;
120+
handler += OnGuiLeft;
106121
onGuiHandler.SetValue(container, handler);
107122
#endif
108123
}
109124

110-
private static void OnGui()
125+
private static void OnGuiLeft()
111126
{
112-
if (!IsToolbarAllowed || !IsToolbarValid)
127+
if (!IsToolbarAllowed || !IsLeftToolbarValid)
113128
{
114129
return;
115130
}
116131

117132
#if UNITY_2021_1_OR_NEWER
118133
using (new GUILayout.HorizontalScope())
119134
{
120-
OnToolbarGui.Invoke();
135+
OnToolbarGuiLeft();
121136
}
122137
#else
123138
var screenWidth = EditorGUIUtility.currentViewWidth;
@@ -139,12 +154,25 @@ private static void OnGui()
139154
{
140155
using (new GUILayout.HorizontalScope())
141156
{
142-
OnToolbarGui?.Invoke();
157+
OnToolbarGuiLeft();
143158
}
144159
}
145160
#endif
146161
}
147162

163+
private static void OnGuiRight()
164+
{
165+
if (!IsToolbarAllowed || !IsRightToolbarValid)
166+
{
167+
return;
168+
}
169+
170+
using (new EditorGUILayout.HorizontalScope())
171+
{
172+
OnToolbarGuiRight();
173+
}
174+
}
175+
148176
public static void Repaint()
149177
{
150178
if (toolbar == null)
@@ -156,11 +184,17 @@ public static void Repaint()
156184
}
157185

158186
public static bool IsToolbarAllowed { get; set; } = true;
159-
public static bool IsToolbarValid => toolbar != null && OnToolbarGui != null;
187+
public static bool IsLeftToolbarValid => toolbar != null && OnToolbarGuiLeft != null;
188+
public static bool IsRightToolbarValid => toolbar != null && OnToolbarGuiRight != null;
160189
public static float FromToolsOffset { get; set; } = 400.0f;
161190
public static float FromStripOffset { get; set; } = 150.0f;
162191

192+
#pragma warning disable 0067
193+
[Obsolete("Use OnToolbarGuiLeft instead")]
163194
public static event Action OnToolbarGui;
195+
#pragma warning restore 0067
196+
public static event Action OnToolbarGuiLeft;
197+
public static event Action OnToolbarGuiRight;
164198

165199
private static class Style
166200
{

Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ internal static bool GetIsEditorExpanded(Editor editor)
5252
/// </summary>
5353
internal static void SetIsEditorExpanded(Editor editor, bool value)
5454
{
55-
InternalEditorUtility.SetIsInspectorExpanded(editor.target, true);
55+
InternalEditorUtility.SetIsInspectorExpanded(editor.target, value);
5656
//NOTE: in older versions Editor's foldouts are based on the m_IsVisible field and the Awake() method
5757
#if !UNITY_2019_1_OR_NEWER
5858
const string isVisibleFieldName = "m_IsVisible";
5959
var isVisible = editor.GetType().GetField(isVisibleFieldName,
6060
BindingFlags.Instance | BindingFlags.NonPublic);
6161
if (isVisible != null)
6262
{
63-
isVisible.SetValue(editor, true);
63+
isVisible.SetValue(editor, value);
6464
}
6565
#endif
6666
}

0 commit comments

Comments
 (0)