UGUI-穿透点击、引导区域镂空点击

bool ICanvasRaycastFilter.IsRaycastLocationValid(Vector2 screenPos, Camera eventCamera)
{
if (null == _target) return true;
// 将目标对象范围内的事件镂空(使其穿过)
return !RectTransformUtility.RectangleContainsScreenPoint(_target, screenPos, eventCamera);
}

IsRaycastLocationValid:
解释:Given a point and a camera is the raycast valid.–>给定一个点和一个摄像机是有效的光线投射。
RectTransformUtility.RectangleContainsScreenPoint:
解释:Does the RectTransform contain the screen point as seen from the given camera?–》RectTransform是否包含从给定摄像机中看到的屏幕点?

RectangleContainsScreenPoint的作用:判断第二个参数代表的位置(鼠标的位置)是否在第一个参数rect的范围内
IsRaycastLocationValid的作用:判断是否投射到物体上
true:投射到为体上,不能穿透
false:没有投射到为体上,可以穿透

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值