Skip to content

Commit fbbd8e9

Browse files
committed
fix(units): use OnMouseDown for single click selection
1 parent 371937f commit fbbd8e9

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

‎Assets/Scripts/Units/UnitManager.cs‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ protected static MaterialPropertyBlock _MaterialPropertyBlock
3131
public bool IsSelected { get => _selected; }
3232
private int _selectIndex = -1;
3333
public int SelectIndex { get => _selectIndex; }
34-
private bool _hovered = false;
3534

3635
public GameObject healthbar;
3736
protected Renderer _healthbarRenderer;
@@ -53,24 +52,13 @@ private void Awake()
5352
}
5453
}
5554

56-
private void OnMouseEnter()
55+
private void OnMouseDown()
5756
{
58-
_hovered = true;
59-
}
60-
61-
private void OnMouseExit()
62-
{
63-
_hovered = false;
64-
}
65-
66-
private void Update()
67-
{
68-
if (_hovered && Input.GetMouseButtonDown(0))
69-
Select(
70-
true,
71-
Input.GetKey(KeyCode.LeftShift) ||
72-
Input.GetKey(KeyCode.RightShift)
73-
);
57+
Select(
58+
true,
59+
Input.GetKey(KeyCode.LeftShift) ||
60+
Input.GetKey(KeyCode.RightShift)
61+
);
7462
}
7563

7664
public void Initialize(Unit unit)

0 commit comments

Comments
 (0)