49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
#if UNITY_EDITOR
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
/********************************************************************************
|
||
*Create By CG
|
||
*Function RaycastTarget管理(此处如果完全用不到交互,可以将GraphicRaycaster脚本去掉)
|
||
*********************************************************************************/
|
||
namespace ZXK.UTility
|
||
{
|
||
public class RaycastTargetManager : MonoBehaviour
|
||
{
|
||
void OnDrawGizmos()
|
||
{
|
||
Vector3[] s_fourCorners = new Vector3[4];
|
||
foreach (MaskableGraphic g in GameObject.FindObjectsOfType<MaskableGraphic>())
|
||
{
|
||
if (g.raycastTarget)
|
||
{
|
||
RectTransform rectTransform = g.transform as RectTransform;
|
||
rectTransform.GetWorldCorners(s_fourCorners);
|
||
Gizmos.color = Color.red;
|
||
for (int i = 0; i < 4; i++)
|
||
Gizmos.DrawLine(s_fourCorners[i], s_fourCorners[(i + 1) % 4]);
|
||
|
||
}
|
||
}
|
||
}
|
||
[ContextMenu("关闭所有射线接收")]
|
||
public void RaycastTargetAllCallOff()
|
||
{
|
||
foreach (MaskableGraphic g in GameObject.FindObjectsOfType<MaskableGraphic>())
|
||
{
|
||
g.raycastTarget = false;
|
||
}
|
||
}
|
||
[ContextMenu("打开所有射线接收")]
|
||
public void RaycastTargetAllCallOn()
|
||
{
|
||
foreach (MaskableGraphic g in GameObject.FindObjectsOfType<MaskableGraphic>())
|
||
{
|
||
g.raycastTarget = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endif
|