ICanvasRaycastFilter

作者:追风剑情 发布于:2019-4-3 13:21 分类:Unity3d

用于UGUI Canvas做射线过滤检测

示例


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RaycastValidity: MonoBehaviour, ICanvasRaycastFilter
{
    public bool IsRaycast;
    /// <summary>
    /// Canvas射线检测过滤器接口
    /// </summary>
    /// <param name="sp">屏幕空间</param>
    /// <param name="eventCamera">发出射线的摄像机</param>
    /// <returns></returns>
    public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
    {
        //false: GUI Canvas忽略射线检测
        //true: GUI Canvas接受射线检测
        return IsRaycast;
    }
}


标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号