0.6.3: Fixed issue, where toolbar items didn't accept mouse input in 2021 or newer versions

This commit is contained in:
Anders Ejlersen 2021-06-21 10:01:49 +02:00
parent 17c55cd03c
commit 99c83ea6d3
9 changed files with 186 additions and 73 deletions

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using Game.NavigationTool.Editor.Toolbar;
using JetBrains.Annotations;
using UnityEditor;
using UnityEditorInternal;
@ -9,17 +8,16 @@ using UTools = UnityEditor.Tools;
namespace Game.NavigationTool.Editor.Tools
{
[UsedImplicitly]
internal sealed class ToolUICanvasPicker : IToolbarDrawer
internal sealed class ToolUICanvasPicker : AbstractToolbarDrawer
{
public bool Visible => true;
public bool Enabled => (UTools.visibleLayers & (1 << LayerMask.NameToLayer("UI"))) != 0;
public EToolbarPlacement Placement => EToolbarPlacement.Left;
public override bool Enabled => (UTools.visibleLayers & (1 << LayerMask.NameToLayer("UI"))) != 0;
public override EToolbarPlacement Placement => EToolbarPlacement.Left;
private static bool IS_DIRTY = true;
private static string[] OPTIONS = new string[0];
private static int[] INSTANCE_IDS = new int[0];
private void Initialize()
private static void Initialize()
{
if (!IS_DIRTY)
return;
@ -48,13 +46,13 @@ namespace Game.NavigationTool.Editor.Tools
INSTANCE_IDS = listIds.ToArray();
IS_DIRTY = false;
}
public void Update()
public override void Update()
{
Initialize();
}
public void Draw(Rect rect, Styles styles)
protected override void Draw(Rect rect)
{
Initialize();
int temp = EditorGUI.Popup(rect, 0, OPTIONS, styles.popup);
@ -62,8 +60,8 @@ namespace Game.NavigationTool.Editor.Tools
if (temp != 0 && OPTIONS.Length != 1)
Focus(INSTANCE_IDS[temp]);
}
public float CalculateWidth()
public override float CalculateWidth()
{
return 100.0f;
}