static Vector3[] fourCorners = new Vector3[4];
private void Awake()
{
// 关闭移动设备上的显示
if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
{
}
else
{
this.enabled = false;
}
}
void OnDrawGizmos()
{
foreach (MaskableGraphic g in GameObject.FindObjectsOfType<MaskableGraphic>())
{
if (g.raycastTarget)
{
RectTransform rectTransform = g.transform as RectTransform;
rectTransform.GetWorldCorners(fourCorners);
Gizmos.color = Color.red;
for (int i = 0; i < 4; i++)
Gizmos.DrawLine(fourCorners[i], fourCorners[(i + 1) % 4]);
}
}
}
Unity Scene视图显示所有开启射线的UI
最新推荐文章于 2024-07-08 20:25:41 发布