Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
843 B

  1. using System.Runtime.InteropServices;
  2. using UnityEngine;
  3. namespace Oculus.Platform
  4. {
  5. public class CallbackRunner : MonoBehaviour
  6. {
  7. [DllImport(CAPI.DLL_NAME)]
  8. static extern void ovr_UnityResetTestPlatform();
  9. public bool IsPersistantBetweenSceneLoads = true;
  10. void Awake()
  11. {
  12. var existingCallbackRunner = FindObjectOfType<CallbackRunner>();
  13. if (existingCallbackRunner != this)
  14. {
  15. Debug.LogWarning("You only need one instance of CallbackRunner");
  16. }
  17. if (IsPersistantBetweenSceneLoads)
  18. {
  19. DontDestroyOnLoad(gameObject);
  20. }
  21. }
  22. void Update()
  23. {
  24. Request.RunCallbacks();
  25. }
  26. void OnDestroy()
  27. {
  28. #if UNITY_EDITOR
  29. ovr_UnityResetTestPlatform();
  30. #endif
  31. }
  32. void OnApplicationQuit()
  33. {
  34. Callback.OnApplicationQuit();
  35. }
  36. }
  37. }