오브젝트 선택창
This commit is contained in:
28
Assets/Scripts/ClickHighlight.cs
Normal file
28
Assets/Scripts/ClickHighlight.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user