Created
June 19, 2020 10:24
-
-
Save edwonedwon/45b1970ee82c4b684cba6b89cd1ddcc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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