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 UnityEditor;
using UnityEngine;
#if UNITY_2021_1_OR_NEWER
using UnityEngine.UIElements;
#endif
namespace Module.NavigationTool.Editor
{
@ -43,7 +46,7 @@ namespace Module.NavigationTool.Editor
{
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];
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);
xLeft -= width + SPACING;
// Note: Magic number for closest right-most item left of play button (2020.3)
if (rect.xMin < 414.0f)
continue;
}
else
{
rect = new Rect(xRight, Y, width, HEIGHT);
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);