Raycast() private method

private Raycast ( Camera cam, Vector2 screenPos, RaycastHit &hit ) : bool
cam Camera
screenPos Vector2
hit UnityEngine.RaycastHit
return bool
    internal GameObject PickObject(ScreenRaycaster raycaster, Vector2 screenPos)
    {
        if (!raycaster || !raycaster.enabled)
        {
            return(null);
        }

        /*if((float)(Time.realtimeSinceStartup - lastTimeRaycast*1.0f) >= timeBetweenRaycast)
         * {
         *      lastTimeRaycast = Time.realtimeSinceStartup;
         *
         *      if( !raycaster.Raycast( screenPos, out lastRaycast ) )
         *              return null;
         * }
         * else
         * {
         *      return null;
         * }*/

        if (!raycaster.Raycast(screenPos, out lastRaycast))
        {
            return(null);
        }

        return(lastRaycast.GameObject);
    }
示例#2
0
    internal GameObject PickObject(ScreenRaycaster raycaster, Vector2 screenPos)
    {
        if (!raycaster || !raycaster.enabled)
        {
            return(null);
        }

        if (!raycaster.Raycast(screenPos, out lastHit))
        {
            return(null);
        }

        return(lastHit.collider.gameObject);
    }