方法一: 通过射线获取,缺点会获取到 射线与已抓取物体之间的物体
public XRRayInteractor rRayInteractor;
bool state = rRayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit raycastHit3D);
if (raycastHit3D.transform)
{
Debug.Log("transform :" + raycastHit3D.transform.name);
}
方法二:
List<IXRSelectInteractable> selectList = rRayInteractor.interactablesSelected;
if (selectList != null && selectList.Count >0)
{
foreach (IXRSelectInteractable item in selectList)
{
Debug.Log("============="+item.transform.name+"=====");
}
}