Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.XR.ARFoundation;
public class ARMeshSupportedEvents : MonoBehaviour
{
public bool debugLog;
public UnityEvent meshSupportedDeviceAwake;
public UnityEvent meshUnsupportedDeviceAwake;
ARMeshManager arMeshManager;
bool arSessionReady;
void Awake()
{
arSessionReady = false;
arMeshManager = FindObjectOfType<ARMeshManager>();
if (arMeshManager != null)
StartCoroutine(Init());
else
Debug.Log("ARMeshManager is null on ARMeshSupportedEvents");
}
IEnumerator Init()
{
while(!arSessionReady)
{
if (ARSession.state == ARSessionState.Ready)
{
arSessionReady = true;
if (arMeshManager.subsystem != null)
{
if (debugLog)
Debug.Log("invoking mesh Supported DeviceAwake()");
meshSupportedDeviceAwake.Invoke();
}
else
{
if (debugLog)
Debug.Log("invoking mesh Unsupported DeviceAwake()");
meshUnsupportedDeviceAwake.Invoke();
}
}
yield return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.