using UnityEngine;

public class ClickHighlight : MonoBehaviour
{
    public Material highlightMaterial; // 반투명한 머터리얼
    private GameObject highlightBox;

    public void ShowHighlight(BoxCollider target)
    {
        if (highlightBox == null)
        {
            highlightBox = GameObject.CreatePrimitive(PrimitiveType.Cube);
            Destroy(highlightBox.GetComponent<Collider>()); // 충돌 제거
            highlightBox.GetComponent<MeshRenderer>().material = highlightMaterial;
        }

        highlightBox.SetActive(true);
        highlightBox.transform.SetParent(target.transform);
        highlightBox.transform.position = target.transform.TransformPoint(target.center);
        highlightBox.transform.rotation = target.transform.rotation;
        highlightBox.transform.localScale = Vector3.Scale(target.transform.lossyScale, target.size);
    }

    public void HideHighlight()
    {
        if (highlightBox) highlightBox.SetActive(false);
    }
}
