Tim Mowrer
5 年前
当前提交
4c278b8b
共有 6 个文件被更改,包括 272 次插入 和 133 次删除
-
97Assets/Scenes/FaceTracking/DisplayFaceInfo.cs
-
211Assets/Scenes/FaceTracking/RearCameraWithFrontCameraFaceMesh.unity
-
2Assets/Scenes/FaceTracking/ToggleCameraFacingDirection.cs.meta
-
43Assets/Scenes/FaceTracking/ToggleCameraFacingDirection.cs
-
52Assets/Scenes/FaceTracking/ToggleManagers.cs
-
0/Assets/Scenes/FaceTracking/ToggleCameraFacingDirection.cs.meta
|
|||
using UnityEngine; |
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
public class ToggleCameraFacingDirection : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
ARCameraManager m_CameraManager; |
|||
|
|||
public ARCameraManager cameraManager |
|||
{ |
|||
get => m_CameraManager; |
|||
set => m_CameraManager = value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
ARSession m_Session; |
|||
|
|||
public ARSession session |
|||
{ |
|||
get => m_Session; |
|||
set => m_Session = value; |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if (m_CameraManager == null || m_Session == null) |
|||
return; |
|||
|
|||
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began) |
|||
{ |
|||
if (m_CameraManager.currentFacingDirection == CameraFacingDirection.User) |
|||
{ |
|||
m_CameraManager.requestedFacingDirection = CameraFacingDirection.World; |
|||
m_Session.requestedTrackingMode = TrackingMode.PositionAndRotation; |
|||
} |
|||
else |
|||
{ |
|||
m_CameraManager.requestedFacingDirection = CameraFacingDirection.User; |
|||
m_Session.requestedTrackingMode = TrackingMode.RotationOnly; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.XR.ARFoundation; |
|||
|
|||
public class ToggleManagers : MonoBehaviour |
|||
{ |
|||
[SerializeField] |
|||
public bool m_PlaneManager; |
|||
|
|||
public bool planeManager |
|||
{ |
|||
get { return m_PlaneManager; } |
|||
set { m_PlaneManager = value; } |
|||
} |
|||
|
|||
[SerializeField] |
|||
public bool m_FaceManager; |
|||
|
|||
public bool faceManager |
|||
{ |
|||
get { return m_FaceManager; } |
|||
set { m_FaceManager = value; } |
|||
} |
|||
|
|||
void ToggleComponent<T>() where T : MonoBehaviour |
|||
{ |
|||
var behaviour = GetComponent<T>(); |
|||
if (behaviour == null) |
|||
return; |
|||
|
|||
behaviour.enabled = !behaviour.enabled; |
|||
var enabledText = behaviour.enabled ? "enabled" : "disabled"; |
|||
Logger.Log($"{typeof(T).Name} {enabledText}"); |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
if (Input.touchCount < 1) |
|||
return; |
|||
|
|||
var touch = Input.touches[0]; |
|||
if (touch.phase == TouchPhase.Began) |
|||
{ |
|||
if (planeManager) |
|||
ToggleComponent<ARPlaneManager>(); |
|||
|
|||
if (faceManager) |
|||
ToggleComponent<ARFaceManager>(); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue