Fix click issues

This commit is contained in:
Vova
2024-05-21 16:00:56 +03:00
parent aeb4ede56c
commit 8507ed820d
4 changed files with 11 additions and 8 deletions
Binary file not shown.
@@ -15,6 +15,7 @@ public class InGameMouseHandler : UnityEngine.Object
private BaseInteractableObject _selectedObject;
private bool _pressControl = false;
private bool _mousePress = false;
public InGameMouseHandler(Camera camera)
{
@@ -23,7 +24,7 @@ public class InGameMouseHandler : UnityEngine.Object
_walkableLayerMask = LayerMask.GetMask("Walking");
var waypointPrefab = Resources.Load("WayPointSign", typeof(WaypointVisual)) as WaypointVisual;
_waypointVisual = Instantiate(waypointPrefab,GameManager.Instance.transform);
_waypointVisual = Instantiate(waypointPrefab, GameManager.Instance.transform);
GameManager.Instance.Input.PlayerAction.PointClick.performed += ClickToMove;
}
@@ -35,9 +36,9 @@ public class InGameMouseHandler : UnityEngine.Object
private void ClickToMove(InputAction.CallbackContext context)
{
if (_pressControl)
if (!_pressControl)
{
_pressControl = false;
GameManager.Instance.UI.ClosePopupMenu();
if (_selectedObject != null)
@@ -50,17 +51,19 @@ public class InGameMouseHandler : UnityEngine.Object
if (Physics.Raycast(_ray, out RaycastHit hit, 100f, _walkableLayerMask))
{
_waypointVisual.SetWaypoint(hit.point);
Player.Instance.GoToPoint( _waypointVisual);
Player.Instance.GoToPoint(_waypointVisual);
}
}
}
_pressControl = false;
}
public void Update()
{
if (Mouse.current.leftButton.wasPressedThisFrame)
_pressControl = !EventSystem.current.IsPointerOverGameObject(PointerInputModule.kMouseLeftId);
{
_pressControl = !EventSystem.current.IsPointerOverGameObject();
}
_ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
if (Physics.Raycast(_ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
{
+1 -1
View File
@@ -7,7 +7,7 @@
"com.unity.collab-proxy": "2.3.1",
"com.unity.formats.fbx": "5.1.1",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.inputsystem": "1.8.1",
"com.unity.inputsystem": "1.8.2",
"com.unity.render-pipelines.universal": "17.0.3",
"com.unity.test-framework": "1.4.3",
"com.unity.timeline": "1.8.6",
+1 -1
View File
@@ -98,7 +98,7 @@
"url": "https://packages.unity.com"
},
"com.unity.inputsystem": {
"version": "1.8.1",
"version": "1.8.2",
"depth": 0,
"source": "registry",
"dependencies": {