Skip to content

Instantly share code, notes, and snippets.

@edwonedwon
Created June 19, 2020 10:24
Show Gist options
  • Save edwonedwon/45b1970ee82c4b684cba6b89cd1ddcc4 to your computer and use it in GitHub Desktop.
Save edwonedwon/45b1970ee82c4b684cba6b89cd1ddcc4 to your computer and use it in GitHub Desktop.
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