-
Notifications
You must be signed in to change notification settings - Fork 1
/
VuforiaSetup.cs
51 lines (43 loc) · 1.11 KB
/
VuforiaSetup.cs
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
44
45
46
47
48
49
50
51
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using Vuforia;
public enum CameraKind
{
Custom = 0,
Color = 1,
Infrared = 2,
Depth = 3,
}
struct DriverUserData
{
public string CameraName;
public CameraKind CameraKind;
}
public class VuforiaSetup : MonoBehaviour
{
public string LibraryName;
public bool ConfigureDriver;
public string CameraName;
public CameraKind CameraKind = CameraKind.Color;
private static DriverUserData _userData;
private static IntPtr _userDataPointer = IntPtr.Zero;
private void Awake()
{
if (ConfigureDriver)
{
_userData = new DriverUserData
{
CameraName = CameraName,
CameraKind = CameraKind
};
_userDataPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DriverUserData)));
Marshal.StructureToPtr(_userData, _userDataPointer, false);
}
#if UNITY_EDITOR
VuforiaApplication.Instance.Initialize();
#else
VuforiaApplication.Instance.Initialize(LibraryName, _userDataPointer);
#endif
}
}