Version: 2019.2
Experimental: this API is experimental and might be changed or removed in the future.

XRRaycastSubsystem.Raycast

マニュアルに切り替える
public bool Raycast (Vector3 screenPoint, List<XRRaycastHit> hitResults, Experimental.XR.TrackableType trackableTypeMask);

パラメーター

screenPointThe screen point from which to cast.
hitResultsThe resulting list of XRRaycastHit.
trackableTypeMaskAn optional mask of TrackableType to raycast against.

説明

Casts a ray from a screen point against selected trackables (e.g., planes and feature points).

Casts a ray from a screen position against selected trackables in the Scene. trackableTypeMask defaults to TrackableType.All.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.XR;

public class RaycastExample : MonoBehaviour { public XRRaycastSubsystem xrRaycast; private List<XRRaycastHit> m_RaycastHits = new List<XRRaycastHit>();

private void Update() { if (Input.GetMouseButton(0)) { // Only raycast against feature points and the exact plane boundries var hitMask = TrackableType.FeaturePoint | TrackableType.PlaneWithinPolygon; if (xrRaycast.Raycast(Input.mousePosition, m_RaycastHits, hitMask)) { Debug.Log("Hit something!"); } } } }

public static void Raycast (Ray ray, Experimental.XR.XRDepthSubsystem depthSubsystem, Experimental.XR.XRPlaneSubsystem planeSubsystem, List<XRRaycastHit> hitResults, Experimental.XR.TrackableType trackableTypeMask, float pointCloudRaycastAngleInDegrees);

パラメーター

rayThe Ray to use.
depthSubsystemThe XRDepthSubsystem to raycast against. May be null.
planeSubsystemThe XRPlaneSubsystem to raycast against. May be null.
hitResultsThe resulting list of XRRaycastHit.
trackableTypeMaskAn optional mask of TrackableType to raycast against.
pointCloudRaycastAngleInDegreesWhen raycasting against feature points, cast a cone with this angle.

説明

Casts a ray using ray against selected trackables (e.g., planes and feature points).

Use this method to raycast against selected trackables in the Scene. trackableTypeMask defaults to TrackableType.All.

When raycasting against TrackableType.FeaturePoint, Unity uses a cone defined by pointCloudRaycastAngleInDegrees. It defaults to 5 degrees.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961