-
Notifications
You must be signed in to change notification settings - Fork 0
/
QRCodeScanner_Controls.cs
120 lines (86 loc) · 3.72 KB
/
QRCodeScanner_Controls.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class QRCodeScanner_Controls : MonoBehaviour
{
//*** Reference to QR Code Scnaner plugin
public QRCodeDecodeController qrCodeDecodeController;
public TextMeshProUGUI qrScanDebugLabel;
public GameObject scanner_Contents;
public List<GameObject> objectsToHideAndReveal;
//*** Reference to menu state controller which switches between the vaiours menu states DocentUI Main , QR code, ConfCode confimation, and Manual Entry
public MenuStateController menuController;
//*** Reference to Confirmation codem enu
public ConfirmationCodeMenu confCodeMenu;
//*** Reference to the menu that handles manual input for Barcodes
public ManualEntryDialogue manualEntryDialogue;
public Image queueMenuBackground;
public Image checkInMenuBackground;
public void Start()
{
//*** Initialize Scanner
InitScanner();
}
public void InitScanner()
{
//*** Assign Scanner callback event which processes QR Scanner result
qrCodeDecodeController.onQRScanFinished += OnQRScanResultRecieived;
}
public void OpenQRScanner()
{
//*** Activate the QR Scanner camera , hide associated Menu State objects
scanner_Contents.SetActive(true);
//*** Hide irrelevant menu objects
RevealOrHidEMenuObjects(false);
//*** Reset Scnaner functionality to reinitiate code
qrCodeDecodeController.Reset();
}
public void CloseQRScanner()
{
//qrCodeDecodeController.StopWork();
//*** Deactivate QR Scnaner game objects
scanner_Contents.SetActive(false);
//*** Activate any assigned menu objects
RevealOrHidEMenuObjects(true);
}
//**** This is hwere the Scanner Result is received, in terms of the EventBrite code it's where we pullthe Barcode value which is then cross referenced with our EventBrite API query results
public void OnQRScanResultRecieived(string pResult)
{
//Debug.Log("QR Scan Result ==" + pResult);
qrScanDebugLabel.text = "Scan Result : " + pResult;
//*** Disable Scnaner Functionality
CloseQRScanner();
//*** Set Menu State To Confirmation Menu to Render Barcode data
menuController.ActivateMenuState(MenuState.menuStateType.ConfirmationMenu);
//*** Take retrieved Barcode Data and Convert to a player using our Barcode as a LINQ query parameter
EventBriteUserInfo oUser = Docent_UI_Manager.instance.eventbriteAPIManager.ConvertAttendeDataToPlayer(pResult);
//*** If User not found , report scan reuslt and exit
if(oUser == null)
{
Debug.Log("Error USer not found!");
oUser = new EventBriteUserInfo();
oUser.first_name = "error";
oUser.last_name = "error";
oUser.emails[0].email = "error";
}
// Set Retrieved User info in confcode Menu
confCodeMenu.SetConfCodText(oUser);
//*** Set QR Scanner data using Barcode ID
manualEntryDialogue.SetLatestQRScannedData(oUser.id);
}
//*** Function to hide and reveal relevant menu objects
public void RevealOrHidEMenuObjects(bool pRevealObjects)
{
queueMenuBackground.enabled = pRevealObjects;
checkInMenuBackground.enabled = pRevealObjects;
//*** Reveal or hide all objects
for (int i = 0; i < objectsToHideAndReveal.Count; i++)
{
objectsToHideAndReveal[i].SetActive(pRevealObjects);
}
//*** Reset Menu state to Checkin / QR Codestate
menuController.ActivateMenuState(MenuState.menuStateType.Manual_Checkin_Entry);
}
}