Only use placement system if is build mode

This commit is contained in:
BOT Alex 2024-04-21 02:21:51 +02:00
parent 05555ed075
commit 8dd3dcefab
1 changed files with 19 additions and 18 deletions

View File

@ -27,7 +27,7 @@ public class CameraSlotClickDetect : MonoBehaviour
RaycastHit hit; RaycastHit hit;
RaycastHit selectHit; RaycastHit selectHit;
if (Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer) && !GameManager.Instance.IsBuildMode) if (!GameManager.Instance.IsBuildMode && Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer))
{ {
var tower = selectHit.collider.gameObject.GetComponentInChildren<Tower>(); var tower = selectHit.collider.gameObject.GetComponentInChildren<Tower>();
if (tower != null) if (tower != null)
@ -40,7 +40,7 @@ public class CameraSlotClickDetect : MonoBehaviour
Debug.LogWarning("TowerCam scpritet is not assigned, assign in the inspector"); Debug.LogWarning("TowerCam scpritet is not assigned, assign in the inspector");
} }
} }
else if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) else if (GameManager.Instance.IsBuildMode && Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{ {
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>(); var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
slotInfo.OnClick(); slotInfo.OnClick();
@ -58,6 +58,7 @@ public class CameraSlotClickDetect : MonoBehaviour
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit; RaycastHit hit;
if (GameManager.Instance.IsBuildMode)
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{ {
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>(); var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();