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 BaseInteractableObject _selectedObject;
|
||||||
private bool _pressControl = false;
|
private bool _pressControl = false;
|
||||||
|
private bool _mousePress = false;
|
||||||
|
|
||||||
public InGameMouseHandler(Camera camera)
|
public InGameMouseHandler(Camera camera)
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,7 @@ public class InGameMouseHandler : UnityEngine.Object
|
|||||||
_walkableLayerMask = LayerMask.GetMask("Walking");
|
_walkableLayerMask = LayerMask.GetMask("Walking");
|
||||||
|
|
||||||
var waypointPrefab = Resources.Load("WayPointSign", typeof(WaypointVisual)) as WaypointVisual;
|
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;
|
GameManager.Instance.Input.PlayerAction.PointClick.performed += ClickToMove;
|
||||||
}
|
}
|
||||||
@@ -35,9 +36,9 @@ public class InGameMouseHandler : UnityEngine.Object
|
|||||||
|
|
||||||
private void ClickToMove(InputAction.CallbackContext context)
|
private void ClickToMove(InputAction.CallbackContext context)
|
||||||
{
|
{
|
||||||
if (_pressControl)
|
if (!_pressControl)
|
||||||
{
|
{
|
||||||
_pressControl = false;
|
|
||||||
GameManager.Instance.UI.ClosePopupMenu();
|
GameManager.Instance.UI.ClosePopupMenu();
|
||||||
|
|
||||||
if (_selectedObject != null)
|
if (_selectedObject != null)
|
||||||
@@ -50,17 +51,19 @@ public class InGameMouseHandler : UnityEngine.Object
|
|||||||
if (Physics.Raycast(_ray, out RaycastHit hit, 100f, _walkableLayerMask))
|
if (Physics.Raycast(_ray, out RaycastHit hit, 100f, _walkableLayerMask))
|
||||||
{
|
{
|
||||||
_waypointVisual.SetWaypoint(hit.point);
|
_waypointVisual.SetWaypoint(hit.point);
|
||||||
Player.Instance.GoToPoint( _waypointVisual);
|
Player.Instance.GoToPoint(_waypointVisual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_pressControl = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (Mouse.current.leftButton.wasPressedThisFrame)
|
if (Mouse.current.leftButton.wasPressedThisFrame)
|
||||||
_pressControl = !EventSystem.current.IsPointerOverGameObject(PointerInputModule.kMouseLeftId);
|
{
|
||||||
|
_pressControl = !EventSystem.current.IsPointerOverGameObject();
|
||||||
|
}
|
||||||
_ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
|
_ray = _camera.ScreenPointToRay(Mouse.current.position.ReadValue());
|
||||||
if (Physics.Raycast(_ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
|
if (Physics.Raycast(_ray, out var mouseRaycastHit, 100f, _selectableLayerMask))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"com.unity.collab-proxy": "2.3.1",
|
"com.unity.collab-proxy": "2.3.1",
|
||||||
"com.unity.formats.fbx": "5.1.1",
|
"com.unity.formats.fbx": "5.1.1",
|
||||||
"com.unity.ide.visualstudio": "2.0.22",
|
"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.render-pipelines.universal": "17.0.3",
|
||||||
"com.unity.test-framework": "1.4.3",
|
"com.unity.test-framework": "1.4.3",
|
||||||
"com.unity.timeline": "1.8.6",
|
"com.unity.timeline": "1.8.6",
|
||||||
|
|||||||
@@ -98,7 +98,7 @@
|
|||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.inputsystem": {
|
"com.unity.inputsystem": {
|
||||||
"version": "1.8.1",
|
"version": "1.8.2",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user