using UnityEngine;
using UnityEngine.XR;
using UnityEngine.XR.ARFoundation;
#if UNITY_IOS && !UNITY_EDITOR
using UnityEngine.XR.ARKit;
#endif // UNITY_IOS && !UNITY_EDITOR
namespace UnityEngine.XR.ARFoundation.Samples
{
public class ToggleMeshClassification : MonoBehaviour
{
///
/// The mesh manager for the scene.
///
[SerializeField]
ARMeshManager m_MeshManager;
///
/// Whether mesh classification should be enabled.
///
[SerializeField]
bool m_ClassificationEnabled = false;
///
/// The mesh manager for the scene.
///
public ARMeshManager meshManager { get => m_MeshManager; set => m_MeshManager = value; }
///
/// Whether mesh classification should be enabled.
///
public bool classificationEnabled
{
get => m_ClassificationEnabled;
set
{
m_ClassificationEnabled = value;
UpdateMeshSubsystem();
}
}
///
/// On enable, update the mesh subsystem with the classification enabled setting.
///
void OnEnable()
{
UpdateMeshSubsystem();
}
///
/// Update the mesh subsystem with the classiication enabled setting.
///
void UpdateMeshSubsystem()
{
#if UNITY_IOS && !UNITY_EDITOR
Debug.Assert(m_MeshManager != null, "mesh manager cannot be null");
if ((m_MeshManager != null) && (m_MeshManager.subsystem is XRMeshSubsystem meshSubsystem))
{
meshSubsystem.SetClassificationEnabled(m_ClassificationEnabled);
}
#endif // UNITY_IOS && !UNITY_EDITOR
}
}
}