AR Foundation演示项目,使用 AR Foundation 4.1.7 并围绕某些功能演示更高级功能。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

63 行
1.5 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class TrackingManager : MonoBehaviour
{
public enum CurrentTrackingState
{
BodyTracking,
WorldTracking
}
public CurrentTrackingState TrackingState;
[SerializeField]
ARSession m_Session;
[SerializeField]
ARSessionOrigin m_SessionOrigin;
[SerializeField]
ARPlaneManager m_PlaneManager;
[SerializeField]
ARPointCloudManager m_PointCloudManager;
[SerializeField]
ARRaycastManager m_RaycastManager;
[SerializeField]
ARHumanBodyManager m_HumanBodyManager;
[SerializeField]
PlaceObjectsOnPlane m_PlaceObjectsOnPlane;
public void SwitchToWorldTracking()
{
SwitchTracking(CurrentTrackingState.WorldTracking);
}
void SwitchTracking(CurrentTrackingState newTrackingState)
{
if (newTrackingState == CurrentTrackingState.BodyTracking)
{
}
else
{
// clean up and remove tracked bodies
m_HumanBodyManager.SetTrackablesActive(false);
m_HumanBodyManager.enabled = false;
// enable subsystems for world tracking
m_PlaneManager.enabled = true;
m_PointCloudManager.enabled = true;
m_RaycastManager.enabled = true;
m_PlaceObjectsOnPlane.enabled = true;
}
}
}