forked from mtysgithub/Qualcomm.Vuforia.UnityExtensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VirtualButtonImpl.cs
91 lines (81 loc) · 2.38 KB
/
VirtualButtonImpl.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Runtime.InteropServices;
using UnityEngine;
internal class VirtualButtonImpl : VirtualButton
{
private RectangleData mArea;
private int mID;
private bool mIsEnabled;
private string mName;
private DataSetImpl mParentDataSet;
private ImageTarget mParentImageTarget;
public VirtualButtonImpl(string name, int id, RectangleData area, ImageTarget imageTarget, DataSet dataSet)
{
this.mName = name;
this.mID = id;
this.mArea = area;
this.mIsEnabled = true;
this.mParentImageTarget = imageTarget;
this.mParentDataSet = (DataSetImpl) dataSet;
}
public override bool SetArea(RectangleData area)
{
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RectangleData)));
Marshal.StructureToPtr(area, ptr, false);
int num = QCARWrapper.Instance.VirtualButtonSetAreaRectangle(this.mParentDataSet.DataSetPtr, this.mParentImageTarget.Name, this.Name, ptr);
Marshal.FreeHGlobal(ptr);
if (num == 0)
{
Debug.LogError("Virtual Button area rectangle could not be set.");
return false;
}
return true;
}
public override bool SetEnabled(bool enabled)
{
if (QCARWrapper.Instance.VirtualButtonSetEnabled(this.mParentDataSet.DataSetPtr, this.mParentImageTarget.Name, this.mName, enabled ? 1 : 0) == 0)
{
Debug.LogError("Virtual Button enabled value could not be set.");
return false;
}
this.mIsEnabled = enabled;
return true;
}
public override bool SetSensitivity(VirtualButton.Sensitivity sensitivity)
{
if (QCARWrapper.Instance.VirtualButtonSetSensitivity(this.mParentDataSet.DataSetPtr, this.mParentImageTarget.Name, this.mName, (int) sensitivity) == 0)
{
Debug.LogError("Virtual Button sensitivity could not be set.");
return false;
}
return true;
}
public override RectangleData Area
{
get
{
return this.mArea;
}
}
public override bool Enabled
{
get
{
return this.mIsEnabled;
}
}
public override int ID
{
get
{
return this.mID;
}
}
public override string Name
{
get
{
return this.mName;
}
}
}