diff --git a/Assets/Scripts/Drag&Drop/DraggablePlaceholder.cs b/Assets/Scripts/Drag&Drop/DraggablePlaceholder.cs index e8030e4..a9cb7c7 100644 --- a/Assets/Scripts/Drag&Drop/DraggablePlaceholder.cs +++ b/Assets/Scripts/Drag&Drop/DraggablePlaceholder.cs @@ -1,6 +1,7 @@ using Codice.CM.Client.Differences; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; public abstract class DraggablePlaceholder : MonoBehaviour @@ -25,6 +26,8 @@ public abstract class DraggablePlaceholder : MonoBehaviour { get => _outlineRenderers; } + + private List _allRenderers = new List(); /// /// calculate level boundaries and finds main camera. @@ -35,6 +38,8 @@ public abstract class DraggablePlaceholder : MonoBehaviour _lvlBoundsCache = LevelManager.Instance.CurrentLevel.CalculateBounds(); _lvlBoundsCache.xMax += 1; _lvlBoundsCache.yMax += 1; + + _allRenderers = GetComponentsInChildren().ToList(); UpdatePosition(); } @@ -68,7 +73,16 @@ public abstract class DraggablePlaceholder : MonoBehaviour var mousePos = Vector3Int.RoundToInt(_mainCamCache.ScreenToWorldPoint(Input.mousePosition)); mousePos.z = 0; - if (!_lvlBoundsCache.Contains(mousePos)) return; + if (!_lvlBoundsCache.Contains(mousePos)) + { + _canBePlacedHere = false; + _allRenderers.ForEach(x => x.enabled = false); + } + else + { + _canBePlacedHere = true; + _allRenderers.ForEach(x => x.enabled = true); + } transform.position = mousePos; }