From 30e7df55e6a0d5aa24f3307d2fbbcac026aaab86 Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sun, 21 Apr 2024 00:38:10 +0200 Subject: [PATCH] fix? --- .../PlacementSystem/CameraSlotClickDetect.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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; } }