fix layer mask detection

This commit is contained in:
Vova
2023-12-11 14:48:07 +02:00
parent 4e0787287b
commit bf088009f6
2 changed files with 16 additions and 168 deletions
+11 -11
View File
@@ -3,12 +3,12 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class InGameMouseHandler:UnityEngine.Object
public class InGameMouseHandler : UnityEngine.Object
{
private LayerMask _selectableLayerMask;
private LayerMask _walkableLayerMask;
private WaypointVisual _waypointVisual;
private Ray _ray;
@@ -21,11 +21,11 @@ public class InGameMouseHandler:UnityEngine.Object
public InGameMouseHandler(Camera camera)
{
_camera = camera;
_selectableLayerMask =LayerMask.NameToLayer("Selectable");
_walkableLayerMask = LayerMask.NameToLayer("Walking");
_selectableLayerMask = LayerMask.GetMask("Selectable");
_walkableLayerMask = LayerMask.GetMask("Walking");
var waypointPrefab = Resources.Load("WayPointSign", typeof(WaypointVisual)) as WaypointVisual;
_waypointVisual =Instantiate(waypointPrefab);
var waypointPrefab = Resources.Load("WayPointSign", typeof(WaypointVisual)) as WaypointVisual;
_waypointVisual = Instantiate(waypointPrefab);
GameManager.Instance.Input.PlayerAction.PointClick.performed += ClickToMove;
}
@@ -58,10 +58,10 @@ public class InGameMouseHandler:UnityEngine.Object
public void Update()
{
_ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
if(EventSystem.current.IsPointerOverGameObject())
{
return;
}
//if(EventSystem.current.IsPointerOverGameObject())
//{
// return;
//}
//hide rounded menu
if (Physics.Raycast(_ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
{