您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.4 KiB

using UnityEngine.XR.ARFoundation;
namespace UnityEngine.XR.ARFoundation.Samples
{
public class CameraSwapper : MonoBehaviour
{
/// <summary>
/// The camera manager for switching the camera direction.
/// </summary>
public ARCameraManager cameraManager
{
get => m_CameraManager;
set => m_CameraManager = value;
}
[SerializeField]
ARCameraManager m_CameraManager;
/// <summary>
/// On button press callback to toggle the requested camera facing direction.
/// </summary>
public void OnSwapCameraButtonPress()
{
Debug.Assert(m_CameraManager != null, "camera manager cannot be null");
CameraFacingDirection newFacingDirection;
switch (m_CameraManager.requestedFacingDirection)
{
case CameraFacingDirection.World:
newFacingDirection = CameraFacingDirection.User;
break;
case CameraFacingDirection.User:
default:
newFacingDirection = CameraFacingDirection.World;
break;
}
Debug.Log($"Switching ARCameraManager.requestedFacingDirection from {m_CameraManager.requestedFacingDirection} to {newFacingDirection}");
m_CameraManager.requestedFacingDirection = newFacingDirection;
}
}
}