diff --git a/Assets/Scripts/PlacementSystem/CameraSlotClickDetect.cs b/Assets/Scripts/PlacementSystem/CameraSlotClickDetect.cs index febcacc..4388d38 100644 --- a/Assets/Scripts/PlacementSystem/CameraSlotClickDetect.cs +++ b/Assets/Scripts/PlacementSystem/CameraSlotClickDetect.cs @@ -25,18 +25,20 @@ public class CameraSlotClickDetect : MonoBehaviour Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; - if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) - { - var slotInfo = hit.collider.gameObject.GetComponentInParent(); - slotInfo.OnClick(); - GameManager.Instance.SelectedTower = null; - } RaycastHit selectHit; if (Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer) && !GameManager.Instance.IsBuildMode) { var tower = selectHit.collider.gameObject.GetComponentInChildren(); if (tower != null) + { GameManager.Instance.SelectedTower = tower; + } + } + else if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) + { + var slotInfo = hit.collider.gameObject.GetComponentInParent(); + slotInfo.OnClick(); + GameManager.Instance.SelectedTower = null; } }