Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop - 0.14.0 #127

Merged
merged 9 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/activation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: game-ci/unity-request-activation-file@v2
# Upload artifact (Unity_v20XX.X.XXXX.alf)
- name: Expose as artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
testMode: ${{ matrix.testMode }}
artifactsPath: ${{ matrix.testMode }}-artifacts
checkName: ${{ matrix.testMode }} Test Results
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test results for ${{ matrix.testMode }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upm-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: split upm branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: split upm branch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: split upm branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: split upm branch
Expand Down
12 changes: 12 additions & 0 deletions Assets/Editor Toolbox/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 0.14.0 [23.02.2025]

### Added:
- OnToolbarGuiRight callback (ability to draw GUI elements on the right side of the toolbar container); OnToolbarGui replaced with the OnToolbarGuiLeft callback

### Changed:
- Fix fetching private members from base classes in various cases (e.g. [EditorButton] or conditionals)
- Move FolderData to the Runtime assembly to fix issues caused by the Visual Scripting package
- Fix minor rendering issues caused by the ReoerdableList's footer position
- Fix clearing cached Editor instances in the [InLineEditor] (fix for the AudioClip still playing)
- Improve displaying [SerializeReference]-based properties in the multi-editing mode

## 0.13.2 [29.11.2024]

### Added:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public bool TryGetValue(string source, object declaringObject, out object value)
}

var type = declaringObject.GetType();
var info = type.GetField(source, ReflectionUtility.allBindings);
var info = ReflectionUtility.GetField(type, source);
if (info == null)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Reflection;

namespace Toolbox.Editor.Drawers
namespace Toolbox.Editor.Drawers
{
public class MethodValueExtractor : IValueExtractor
{
Expand All @@ -14,7 +11,7 @@ public bool TryGetValue(string source, object declaringObject, out object value)
}

var type = declaringObject.GetType();
var info = type.GetMethod(source, ReflectionUtility.allBindings, null, CallingConventions.Any, new Type[0], null);
var info = ReflectionUtility.GetMethod(type, source);
if (info == null)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public bool TryGetValue(string source, object declaringObject, out object value)
}

var type = declaringObject.GetType();
var info = type.GetProperty(source, ReflectionUtility.allBindings);
var info = ReflectionUtility.GetProperty(type, source);
if (info == null)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Toolbox.Editor.Drawers
{
using Toolbox.Editor.Folders;
using Toolbox.Folders;

[CustomPropertyDrawer(typeof(FolderData))]
internal class FolderDataDrawer : PropertyDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class EditorButtonAttributeDrawer : ToolboxDecoratorDrawer<EditorButtonAt
{
private MethodInfo GetMethod(EditorButtonAttribute attribute, object[] targetObjects, string methodName)
{
var methodInfo = ReflectionUtility.GetObjectMethod(methodName, targetObjects);
var methodInfo = ReflectionUtility.GetMethod(methodName, targetObjects);
if (methodInfo == null)
{
ToolboxEditorLog.AttributeUsageWarning(attribute, string.Format("{0} method not found.", methodName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static MethodInfo FindMethod(SerializedObject target, string methodName,
return null;
}

var methodInfo = ReflectionUtility.GetObjectMethod(methodName, target);
var methodInfo = ReflectionUtility.GetMethod(methodName, target);
if (methodInfo == null)
{
ToolboxEditorLog.AttributeUsageWarning(typeof(ReorderableListExposedAttribute), string.Format("{0} method not found.", methodName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static InLineEditorAttributeDrawer()

private static readonly PropertyDataStorage<Editor, InLineEditorAttribute> storage;


private Editor GetTargetsEditor(SerializedProperty property, InLineEditorAttribute attribute)
{
var editor = storage.ReturnItem(property, attribute);
Expand Down Expand Up @@ -108,7 +107,6 @@ private void DrawEditor(Editor editor, bool disableEditor, bool drawPreview, boo
}
}


/// <summary>
/// Handles the property drawing process and tries to create a inlined version of the <see cref="Editor"/>.
/// </summary>
Expand Down Expand Up @@ -151,15 +149,17 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
DrawEditor(editor, attribute);
}
}
else
{
storage.ClearItem(property);
}
}


public override bool IsPropertyValid(SerializedProperty property)
{
return property.propertyType == SerializedPropertyType.ObjectReference;
}


private static class Style
{
internal static readonly GUIStyle backgroundStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,38 @@ private Type GetParentType(ReferencePickerAttribute attribute, SerializedPropert
return fieldType;
}

private static Type GetCurrentManagedReferenceType(SerializedProperty property, out bool hasMixedValues)
{
var fullTypeName = property.managedReferenceFullTypename;
hasMixedValues = false;
TypeUtility.TryGetTypeFromManagedReferenceFullTypeName(fullTypeName, out var targetType);

var currentSerializedObject = property.serializedObject;
if (currentSerializedObject.isEditingMultipleObjects)
{
var targets = currentSerializedObject.targetObjects;
foreach (var target in targets)
{
using (var tempSerializedObject = new SerializedObject(target))
{
var tempProperty = tempSerializedObject.FindProperty(property.propertyPath);
if (tempProperty.managedReferenceFullTypename != fullTypeName)
{
hasMixedValues = true;
break;
}
}
}
}

return targetType;
}

private void CreateTypeProperty(SerializedProperty property, Type parentType, ReferencePickerAttribute attribute, Rect position)
{
TypeUtility.TryGetTypeFromManagedReferenceFullTypeName(property.managedReferenceFullTypename, out var currentType);
var currentType = GetCurrentManagedReferenceType(property, out var hasMixedValues);
var hadMixedValues = EditorGUI.showMixedValue;
EditorGUI.showMixedValue = hasMixedValues;
typeField.OnGui(position, attribute.AddTextSearchField, (type) =>
{
try
Expand All @@ -70,6 +99,7 @@ private void CreateTypeProperty(SerializedProperty property, Type parentType, Re
ToolboxEditorLog.LogWarning("Invalid attempt to update disposed property.");
}
}, currentType, parentType);
EditorGUI.showMixedValue = false;
}

private void UpdateTypeProperty(SerializedProperty property, Type targetType, ReferencePickerAttribute attribute)
Expand Down
4 changes: 4 additions & 0 deletions Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ protected virtual bool DoListFooter(Rect footerRect)
return false;
}

footerRect.yMax += Style.footerXOffset;
footerRect.yMin += Style.footerYOffset;
//draw the background on repaint event
if (Event.current.type == EventType.Repaint)
{
Expand Down Expand Up @@ -870,6 +872,8 @@ protected static class Style
#else
internal static readonly float lineHeight = 16.0f;
#endif
internal static readonly float footerXOffset = 0.0f;
internal static readonly float footerYOffset = -1.0f;
internal static readonly float footerWidth = 60.0f;
internal static readonly float footerButtonWidth = 25.0f;
internal static readonly float footerButtonHeight = 13.0f;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Editor Toolbox/Editor/ToolboxEditorProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Toolbox.Editor
{
using Toolbox.Editor.Folders;
using Toolbox.Folders;

/// <summary>
/// Static GUI representation for the Project Overlay.
Expand Down
2 changes: 1 addition & 1 deletion Assets/Editor Toolbox/Editor/ToolboxEditorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
namespace Toolbox.Editor
{
using Toolbox.Editor.Drawers;
using Toolbox.Editor.Folders;
using Toolbox.Editor.Hierarchy;
using Toolbox.Folders;

internal interface IToolboxGeneralSettings
{ }
Expand Down
64 changes: 49 additions & 15 deletions Assets/Editor Toolbox/Editor/ToolboxEditorToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static ToolboxEditorToolbar()

private static IEnumerator Initialize()
{
while (ToolboxEditorToolbar.toolbar == null)
while (toolbar == null)
{
var toolbars = Resources.FindObjectsOfTypeAll(toolbarType);
if (toolbars == null || toolbars.Length == 0)
Expand All @@ -63,15 +63,15 @@ private static IEnumerator Initialize()
}
else
{
ToolboxEditorToolbar.toolbar = toolbars[0];
toolbar = toolbars[0];
}
}

#if UNITY_2021_1_OR_NEWER
var rootField = ToolboxEditorToolbar.toolbar.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
var root = rootField.GetValue(ToolboxEditorToolbar.toolbar) as VisualElement;
var toolbar = root.Q("ToolbarZoneLeftAlign");
var rootField = toolbar.GetType().GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance);
var root = rootField.GetValue(toolbar) as VisualElement;

var toolbarLeftZone = root.Q("ToolbarZoneLeftAlign");
var element = new VisualElement()
{
style =
Expand All @@ -83,10 +83,25 @@ private static IEnumerator Initialize()

var container = new IMGUIContainer();
container.style.flexGrow = 1;
container.onGUIHandler += OnGui;

container.onGUIHandler += OnGuiLeft;
element.Add(container);
toolbar.Add(element);
toolbarLeftZone.Add(element);

var toolbarRightZone = root.Q("ToolbarZoneRightAlign");
var rightElement = new VisualElement()
{
style =
{
flexGrow = 1,
flexDirection = FlexDirection.Row,
}
};

var rightContainer = new IMGUIContainer();
rightContainer.style.flexGrow = 1;
rightContainer.onGUIHandler += OnGuiRight;
rightElement.Add(rightContainer);
toolbarRightZone.Add(rightElement);
#else
#if UNITY_2020_1_OR_NEWER
var backend = guiBackend.GetValue(toolbar);
Expand All @@ -101,23 +116,23 @@ private static IEnumerator Initialize()
var container = elements[0] as IMGUIContainer;
#endif
var handler = onGuiHandler.GetValue(container) as Action;
handler -= OnGui;
handler += OnGui;
handler -= OnGuiLeft;
handler += OnGuiLeft;
onGuiHandler.SetValue(container, handler);
#endif
}

private static void OnGui()
private static void OnGuiLeft()
{
if (!IsToolbarAllowed || !IsToolbarValid)
if (!IsToolbarAllowed || !IsLeftToolbarValid)
{
return;
}

#if UNITY_2021_1_OR_NEWER
using (new GUILayout.HorizontalScope())
{
OnToolbarGui.Invoke();
OnToolbarGuiLeft();
}
#else
var screenWidth = EditorGUIUtility.currentViewWidth;
Expand All @@ -139,12 +154,25 @@ private static void OnGui()
{
using (new GUILayout.HorizontalScope())
{
OnToolbarGui?.Invoke();
OnToolbarGuiLeft();
}
}
#endif
}

private static void OnGuiRight()
{
if (!IsToolbarAllowed || !IsRightToolbarValid)
{
return;
}

using (new EditorGUILayout.HorizontalScope())
{
OnToolbarGuiRight();
}
}

public static void Repaint()
{
if (toolbar == null)
Expand All @@ -156,11 +184,17 @@ public static void Repaint()
}

public static bool IsToolbarAllowed { get; set; } = true;
public static bool IsToolbarValid => toolbar != null && OnToolbarGui != null;
public static bool IsLeftToolbarValid => toolbar != null && OnToolbarGuiLeft != null;
public static bool IsRightToolbarValid => toolbar != null && OnToolbarGuiRight != null;
public static float FromToolsOffset { get; set; } = 400.0f;
public static float FromStripOffset { get; set; } = 150.0f;

#pragma warning disable 0067
[Obsolete("Use OnToolbarGuiLeft instead")]
public static event Action OnToolbarGui;
#pragma warning restore 0067
public static event Action OnToolbarGuiLeft;
public static event Action OnToolbarGuiRight;

private static class Style
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ internal static bool GetIsEditorExpanded(Editor editor)
/// </summary>
internal static void SetIsEditorExpanded(Editor editor, bool value)
{
InternalEditorUtility.SetIsInspectorExpanded(editor.target, true);
InternalEditorUtility.SetIsInspectorExpanded(editor.target, value);
//NOTE: in older versions Editor's foldouts are based on the m_IsVisible field and the Awake() method
#if !UNITY_2019_1_OR_NEWER
const string isVisibleFieldName = "m_IsVisible";
var isVisible = editor.GetType().GetField(isVisibleFieldName,
BindingFlags.Instance | BindingFlags.NonPublic);
if (isVisible != null)
{
isVisible.SetValue(editor, true);
isVisible.SetValue(editor, value);
}
#endif
}
Expand Down
Loading
Loading