Fix click issues
This commit is contained in:
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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user