void OnGUI() { if (CurrentState == State.ShowQRCode) { myQR = generateQR(stats.AnimalType + "," + stats.Happiness + "," + stats.Hunger + "," + stats.SocialRating + "," + stats.XP); if (GUI.Button(new Rect(0, 0, 256, 256), myQR, GUIStyle.none)) { } } if (CurrentState == State.ReadQRCode) { // drawing the camera on screen GUI.DrawTexture(screenRect, camTexture, ScaleMode.ScaleToFit); // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake try { IBarcodeReader barcodeReader = new BarcodeReader(); // decode the current frame var result = barcodeReader.Decode(camTexture.GetPixels32(), camTexture.width, camTexture.height); if (result != null) { Debug.Log("DECODED TEXT FROM QR: " + result.Text); challenge.CheckForCompletion(result.Text); ChallengeTextBox.text = challenge.ToString(); } } catch (System.Exception ex) { Debug.LogWarning(ex.Message); } } }