29 lines
975 B
C#
29 lines
975 B
C#
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
public class ClickHighlight : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public Material highlightMaterial; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><CDB8><EFBFBD>
|
|||
|
|
private GameObject highlightBox;
|
|||
|
|
|
|||
|
|
public void ShowHighlight(BoxCollider target)
|
|||
|
|
{
|
|||
|
|
if (highlightBox == null)
|
|||
|
|
{
|
|||
|
|
highlightBox = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
|||
|
|
Destroy(highlightBox.GetComponent<Collider>()); // <20>浹 <20><><EFBFBD><EFBFBD>
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
}
|