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