BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Platform / Scripts / CallbackRunner.cs

CallbackRunner.cs

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