2025-07-21 18:11:30 +09:00
|
|
|
|
using UnityEngine;
|
2025-05-12 18:00:37 +09:00
|
|
|
|
|
|
|
|
|
|
public class ClickHighlight : MonoBehaviour
|
|
|
|
|
|
{
|
2025-07-21 18:11:30 +09:00
|
|
|
|
public Material highlightMaterial; // 반투명한 머터리얼
|
2025-05-12 18:00:37 +09:00
|
|
|
|
private GameObject highlightBox;
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowHighlight(BoxCollider target)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (highlightBox == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
highlightBox = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
2025-07-21 18:11:30 +09:00
|
|
|
|
Destroy(highlightBox.GetComponent<Collider>()); // 충돌 제거
|
2025-05-12 18:00:37 +09:00
|
|
|
|
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;
|
2025-07-21 18:11:30 +09:00
|
|
|
|
highlightBox.transform.localScale = Vector3.Scale(target.transform.lossyScale, target.size*1.1f);
|
2025-05-12 18:00:37 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void HideHighlight()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (highlightBox) highlightBox.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|