1.0.0: Fixed issue, where toolbar elements could overlap with other toolbar elements in Unity 2020 and older

This commit is contained in:
Anders Ejlersen 2021-11-10 19:40:38 +01:00
parent 0a2858f8ca
commit bf2b2f1383
3 changed files with 43 additions and 11 deletions

View file

@ -1,7 +1,10 @@
using Module.NavigationTool.Editor.Toolbar; using Module.NavigationTool.Editor.Toolbar;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
#if UNITY_2021_1_OR_NEWER
using UnityEngine.UIElements; using UnityEngine.UIElements;
#endif
namespace Module.NavigationTool.Editor namespace Module.NavigationTool.Editor
{ {
@ -43,7 +46,7 @@ namespace Module.NavigationTool.Editor
{ {
const float HEIGHT = 22.0f; const float HEIGHT = 22.0f;
for (var i = 0; i < DRAWERS.Length; i++) for (int i = DRAWERS.Length - 1; i >= 0; i--)
{ {
AbstractToolbarDrawer drawer = DRAWERS[i]; AbstractToolbarDrawer drawer = DRAWERS[i];
var rect = new Rect(0.0f, 0.0f, drawer.CalculateWidth(), HEIGHT); var rect = new Rect(0.0f, 0.0f, drawer.CalculateWidth(), HEIGHT);
@ -86,11 +89,21 @@ namespace Module.NavigationTool.Editor
{ {
rect = new Rect(xLeft - width, Y, width, HEIGHT); rect = new Rect(xLeft - width, Y, width, HEIGHT);
xLeft -= width + SPACING; xLeft -= width + SPACING;
// Note: Magic number for closest right-most item left of play button (2020.3)
if (rect.xMin < 414.0f)
continue;
} }
else else
{ {
rect = new Rect(xRight, Y, width, HEIGHT); rect = new Rect(xRight, Y, width, HEIGHT);
xRight += width + SPACING; xRight += width + SPACING;
Debug.Log(rect.xMax);
// Note: Magic number for closest left-most item right of play button (2020.3)
// If you don't have collab, which no sane person has
if (rect.xMax < 642.0f)
continue;
} }
drawer.Setup(rect); drawer.Setup(rect);

View file

@ -59,17 +59,18 @@ namespace Module.NavigationTool.Editor.Toolbar
private static VisualElement CreateParent(VisualElement root, string query, bool isLeft) private static VisualElement CreateParent(VisualElement root, string query, bool isLeft)
{ {
VisualElement parent = root.Q(query); VisualElement parent = root.Q(query);
VisualElement result;
var result = new VisualElement
{
style = {
flexGrow = 1,
flexDirection = FlexDirection.Row
}
};
if (isLeft) if (isLeft)
{ {
result = new VisualElement
{
style = {
flexGrow = 1,
flexDirection = FlexDirection.Row
}
};
result.Add(new VisualElement result.Add(new VisualElement
{ {
style = { style = {
@ -77,6 +78,24 @@ namespace Module.NavigationTool.Editor.Toolbar
} }
}); });
} }
else
{
result = new VisualElement
{
style = {
flexGrow = 1,
flexDirection = FlexDirection.RowReverse
}
};
result.Add(new VisualElement
{
style =
{
flexGrow = 1
}
});
}
parent.Add(result); parent.Add(result);
return result; return result;

View file

@ -1,6 +1,6 @@
{ {
"name": "com.module.navigationtool", "name": "com.module.navigationtool",
"version": "0.8.3", "version": "1.0.0",
"displayName": "Module.NavigationTool", "displayName": "Module.NavigationTool",
"description": "Support for navigation tools, like favorites, history and toolbars", "description": "Support for navigation tools, like favorites, history and toolbars",
"unity": "2019.2", "unity": "2019.2",