public void PlantButtonOnClick() { try { IBarcodeReader barcodeReader = new BarcodeReader(); // decode the current frame var result = barcodeReader.Decode(backCamera.GetPixels32(), backCamera.width, backCamera.height); if (result != null) { Debug.Log("DECODED TEXT FROM QR: " + result.Text); } QrResult = result.Text; JsonEntity jsonEntity = new JsonEntity(); jsonEntity.JsonFlag = "FactoryQR"; jsonEntity.JsonObject = QrResult; string jsonString = JsonUtility.ToJson(jsonEntity); PlantQrCommunication qrCommunication = new PlantQrCommunication(); qrCommunication.SendDataToServer(jsonString); //LoadScene which displays OptimisedRootList of Machines SceneManager.LoadScene("YellowStateMachines"); } catch (Exception ex) { Debug.LogWarning(ex.Message); //QrResult = ""; } }
// Use this for initialization void Start() { InformationText.text = "These are the yellow stated machines. " + "If you think they have emergency situation " + "please select the machines from the list by clicking to checkbox " + "Checked means Urgent, unchecked means Not Urgent!"; //The data comes from here is a list of Machines. PlantQrCommunication qrCommunication = new PlantQrCommunication(); ServerResponse = qrCommunication.ReceiveDataFromServer(); //Deserilize the received data to MachineEntityList YellowStateMachinesList = JsonUtility.FromJson <List <MachineEntity> >(ServerResponse); Debug.Log(YellowStateMachinesList); // 2. Iterate through the data, // instantiate prefab, // set the data, // add it to panel size = YellowStateMachinesList.Count; if (size == 0) { Debug.Log("This list is empty"); //Send empty list to the server //Call Optimised List in the begining of the next scene SceneManager.LoadScene("OptimmisedRoot"); } else { GameObject newMachine = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newMachine.GetComponent <ListItemController>(); controller.MachineId.text = YellowStateMachinesList[0].id; controller.OperationToDo.text = YellowStateMachinesList[0].operationToDo; newMachine.transform.parent = ContentPanel.transform; newMachine.transform.localScale = Vector3.one; } }