From 3c1a94257fa01e5e23f8d1d28db4cb2ffa2b2d38 Mon Sep 17 00:00:00 2001 From: Felix Boucher Date: Mon, 30 Oct 2023 21:28:21 -0400 Subject: [PATCH 1/2] fix detection range problem : detection range didn't show anymore on placeholders solution : calculate detection range from collider's offset and size instead of it's bound --- Assets/Scripts/Detection.cs | 7 ++++--- Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Detection.cs b/Assets/Scripts/Detection.cs index 045534b..ff62d07 100644 --- a/Assets/Scripts/Detection.cs +++ b/Assets/Scripts/Detection.cs @@ -10,11 +10,12 @@ public class Detection : MonoBehaviour { get { - if (!_collider) _collider = GetComponent(); - var bounds = _collider.bounds; - return new Rect(bounds.min - transform.position, bounds.size); + var _coll = GetComponent(); + var rect = new Rect(_coll.offset, _coll.size); + return rect; } } + [SerializeField] private Entity _entityLinked; protected virtual void Start() diff --git a/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs b/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs index 2913def..ef6e0b6 100644 --- a/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs +++ b/Assets/Scripts/Drag&Drop/GameObjectPlacementButton.cs @@ -58,11 +58,11 @@ public class GameObjectPlacementButton : UnitPlacementButton var rend = detection.AddComponent(); rend.sprite = _detectionRangeSprite; rend.sortingLayerName = "Character"; - rend.sortingOrder = 0; + rend.sortingOrder = 1; rend.color = new Color(1, 1, 1, 0.2f); detection.transform.SetParent(placeholder.transform); - detection.transform.localPosition = detectionRect.center; + detection.transform.localPosition = detectionRect.position; detection.transform.localScale = detectionRect.size; } } \ No newline at end of file From 937624f54fafd20cbc70dd752fa00314139ec795 Mon Sep 17 00:00:00 2001 From: Felix Boucher Date: Tue, 31 Oct 2023 21:12:24 -0400 Subject: [PATCH 2/2] remove underscore --- Assets/Scripts/Detection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Detection.cs b/Assets/Scripts/Detection.cs index ff62d07..8b55fd6 100644 --- a/Assets/Scripts/Detection.cs +++ b/Assets/Scripts/Detection.cs @@ -10,8 +10,8 @@ public class Detection : MonoBehaviour { get { - var _coll = GetComponent(); - var rect = new Rect(_coll.offset, _coll.size); + var coll = GetComponent(); + var rect = new Rect(coll.offset, coll.size); return rect; } }