fixed building outline bug

This commit is contained in:
Adam Salah 2025-07-29 22:19:29 -04:00
parent 61fcd9bf82
commit 74727857ca

View File

@ -40,17 +40,6 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler, IPoin
{ {
Destroy(gameObject); Destroy(gameObject);
} }
if (!_outline && _unitGameObject.TryGetComponent(out House currentBuilding))
{
_outline = new GameObject("Outline");
var rend = _outline.AddComponent<SpriteRenderer>();
rend.sprite = _rangeSprite;
rend.sortingLayerName = "Character";
rend.sortingOrder = 1;
rend.color = new Color(1, 1, 1, 0.2f);
}
} }
void Update() void Update()
@ -106,6 +95,17 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler, IPoin
_unitGameObject = parentGameObject; _unitGameObject = parentGameObject;
_canvas = canvas; _canvas = canvas;
_unitArt.sprite = unitUpgrade.UpgradeCardArt; _unitArt.sprite = unitUpgrade.UpgradeCardArt;
if (_outline == null && _unitGameObject.TryGetComponent(out House currentBuilding))
{
_outline = new GameObject("Outline");
var rend = _outline.AddComponent<SpriteRenderer>();
rend.sprite = _rangeSprite;
rend.sortingLayerName = "Character";
rend.sortingOrder = 1;
rend.color = new Color(1, 1, 1, 0.2f);
}
} }
public void OnPointerEnter(PointerEventData eventData) public void OnPointerEnter(PointerEventData eventData)
{ {
@ -133,8 +133,12 @@ public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler, IPoin
public void OnPointerExit(PointerEventData eventData) public void OnPointerExit(PointerEventData eventData)
{ {
HideTooltip(); HideTooltip();
if (_outline)
{
_outline.SetActive(false); _outline.SetActive(false);
} }
}
private void HideTooltip() private void HideTooltip()
{ {