// Processes the data received from the cloud. private void HandleDriveResponse(Drive.DataContainer dataContainer) { if (dataContainer.QueryType == Drive.QueryType.createTable && dataContainer.objType == "Credentials") { _waitingForServerResponse = false; Debug.Log(dataContainer.msg); } if (dataContainer.QueryType == Drive.QueryType.signup) { _waitingForServerResponse = false; Debug.Log(dataContainer.msg); } if (dataContainer.QueryType == Drive.QueryType.login) { _waitingForServerResponse = false; _isLoggedIn = true; _lastLogon = Drive.SessionContext.lastLogon; _signupDate = Drive.SessionContext.registrationDate; Debug.Log(dataContainer.msg + "\n" + Drive.SessionContext); } if (dataContainer.QueryType == Drive.QueryType.logout) { _waitingForServerResponse = false; _isLoggedIn = false; Debug.Log(dataContainer.msg); } }
private void HandleDriveResponse(Drive.DataContainer dataContainer) { if (dataContainer.QueryType == Drive.QueryType.createBinaryFile) { Debug.LogFormat("Binary file created with name {0} and id {1}, at folder {2}.", dataContainer.fileName, dataContainer.fileId, dataContainer.folderName); } if (dataContainer.QueryType == Drive.QueryType.createTextFile) { Debug.LogFormat("Text file created with name {0} and id {1}, at folder {2}.", dataContainer.fileName, dataContainer.fileId, dataContainer.folderName); } if (dataContainer.QueryType == Drive.QueryType.getBinaryFile) { Debug.Log(dataContainer.msg); byte[] decodedBytes = Convert.FromBase64String(dataContainer.payload); MemoryStream memStream = new MemoryStream(decodedBytes); BinaryFormatter binaryFormatter = new BinaryFormatter(); _playerData = (PlayerInfo)binaryFormatter.Deserialize(memStream); OutputData("Drive binary file"); } if (dataContainer.QueryType == Drive.QueryType.getTextFile) { Debug.Log(dataContainer.msg); _playerData = JsonUtility.FromJson <PlayerInfo>(dataContainer.payload); OutputData("Drive text file"); } }
// Processes the data received from the cloud. private void HandleDriveResponse(Drive.DataContainer dataContainer) { if (dataContainer.objType != localizationTableName) { return; } // First check the type of answer. if (dataContainer.QueryType == Drive.QueryType.getTable) { string rawJSon = dataContainer.payload; Debug.Log("Data from Google Drive received."); // Parse from json to the desired object type. Localization[] localization = JsonHelper.ArrayFromJson <Localization>(rawJSon); localizationData = new List <Localization>(localization); } if (dataContainer.QueryType != Drive.QueryType.createTable || dataContainer.QueryType != Drive.QueryType.createObjects) { Debug.Log(dataContainer.msg); } Drive.responseCallback -= HandleDriveResponse; }
// Processes the data received from the cloud. private void HandleDriveResponse(Drive.DataContainer dataContainer) { if (dataContainer.QueryType == Drive.QueryType.createImageFile) { Debug.LogFormat("Image file created with name {0} and id {1}, at folder {2}.", dataContainer.fileName, dataContainer.fileId, dataContainer.folderName); } if (dataContainer.QueryType == Drive.QueryType.getImageFile) { Debug.Log(dataContainer.msg); byte[] decodedBytes = Convert.FromBase64String(dataContainer.payload); Texture2D tex = new Texture2D(2, 2); tex.LoadImage(decodedBytes, false); _text2d = tex; } }
// Processes the data received from the cloud. public void HandleDriveResponse(Drive.DataContainer dataContainer) { Debug.Log(dataContainer.msg); // If it's getObjectsByField... if (dataContainer.QueryType == Drive.QueryType.getObjectsByField) { string rawJSon = dataContainer.payload; Debug.Log(rawJSon); // Check if the type is correct. if (string.Compare(dataContainer.objType, AllPhotosSheet) == 0) { // Parse from json to the desired object type. PhotoInfo[] photos = JsonHelper.ArrayFromJson <PhotoInfo>(rawJSon); for (int i = 0; i < photos.Length; i++) { Debug.Log("<color=yellow>Object retrieved from the cloud and parsed: \n</color>" + "filename: " + photos[i].filename + "\n" + "dropbox_path: " + photos[i].dropbox_path + "\n" + "year: " + photos[i].year + "\n" + "date: " + photos[i].date + "\n" + "location: " + photos[i].location + "\n" + "notes: " + photos[i].notes + "\n" + "file_type: " + photos[i].location + "\n" + "dropbox_url: " + photos[i].location + "\n"); } } } // If it's getCellValue... if (dataContainer.QueryType == Drive.QueryType.getCellValue) { cellValue = dataContainer.payload; string rawJSon = dataContainer.payload; Debug.Log("getCellValue = " + cellValue); // Check if the type is correct. if (string.Compare(dataContainer.objType, AllPhotosSheet) == 0) { //Debug.Log("<color=yellow>Cell " + ColumnInput.text+ RowInput.text + " contents are: \n</color>" + dataContainer.payload + "\n"); cellValue = dataContainer.payload; photoReview.DebugText.text = cellValue; } ReadinessMessage.text = "Ready. Tap to start."; } // If it's getTable... if (dataContainer.QueryType == Drive.QueryType.getTable) { string rawJSon = dataContainer.payload; // Debug.Log(rawJSon); // Confirm the sheet was of the right type... if (string.Compare(dataContainer.objType, AllPhotosSheet) == 0) { // Parse from json to the desired object type. PhotoInfo[] photos = JsonHelper.ArrayFromJson <PhotoInfo>(rawJSon); // string logMsg = "<color=yellow>" + photos.Length.ToString() + " objects retrieved from the cloud and parsed:</color>"; // for (int i = 0; i < photos.Length; i++) // { // logMsg += "\n" + // "filename: " + photos[i].filename + "\n" + // "dropbox_path: " + photos[i].dropbox_path + "\n" + // "year: " + photos[i].year + "\n" + // "date: " + photos[i].date + "\n" + // "location: " + photos[i].location + "\n" + // "notes: " + photos[i].notes + "\n" + // "file_type: " + photos[i].location + "\n" + // "dropbox_url: " + photos[i].location + "\n"; //} //Debug.Log(logMsg); ReadinessMessage.text = photos.Length + " photos to review.\nTap to start."; photoReview.StartButton.transform.gameObject.SetActive(true); } } // If it's getAllTables... if (dataContainer.QueryType == Drive.QueryType.getAllTables) { string rawJSon = dataContainer.payload; // The response for this query is a json list of objects that hold two fields: // * objType: the table name (we use for identifying the type). // * payload: the contents of the table in json format. Drive.DataContainer[] tables = JsonHelper.ArrayFromJson <Drive.DataContainer>(rawJSon); // Once we get the list of tables, we could use the objTypes to know the type and convert json to specific objects. // On this example, we will just dump all content to the console, sorted by table name. string logMsg = "<color=yellow>All data tables retrieved from the cloud.\n</color>"; for (int i = 0; i < tables.Length; i++) { logMsg += "\n<color=blue>Table Name: " + tables[i].objType + "</color>\n" + tables[i].payload + "\n"; } Debug.Log(logMsg); } }
// Processes the data received from the cloud. public void HandleDriveResponse(Drive.DataContainer dataContainer) { Debug.Log("In HandleDriveResponse. dataContainer.msg = " + dataContainer.msg); // getTable... if (dataContainer.QueryType == Drive.QueryType.getTable) { string rawJSon = dataContainer.payload; if (string.Compare(dataContainer.objType, AllPhotosSheet) == 0) // AllPhotosSheet { // Parse from json to the desired object type. PhotoInfo[] photos = JsonHelper.ArrayFromJson <PhotoInfo>(rawJSon); allPhotos = photos; // allPhotos is public array of all the photo info // Calculate # of un-reviewed photos notReviewedCount = 0; int forgottenPhotos = 0; for (int i = 0; i < photos.Length; i++) { //if(i < 10) print("fn: " + photos[i].filename + // ", path:" + photos[i].dropbox_path + // ", date: " + photos[i].date); if ((photos[i].date == "" || photos[i].location == "") && (photos[i].forget_photo == "")) { notReviewedCount++; } if (photos[i].forget_photo != "") { forgottenPhotos++; } } PhotoReviewerLogo.gameObject.SetActive(true); ReadinessMessage.text = photos.Length + " photos\n" + forgottenPhotos + " 'forgotten'" + "\n" + notReviewedCount + " still need info"; ReadinessMessage.text = ReadinessMessage.text + "\n\n<color=yellow>Tap to start</color>"; //ReadinessMessage.text = "allPhotos[0].filename = " + allPhotos[0].filename; Debug.Log("*** FINISHED GetAllPHotos() loading at " + System.DateTime.Now.ToLongTimeString()); photoReview.EditorNamePanel.transform.gameObject.SetActive(true); // Show the EditorNamePanel photoReview.StartButton.transform.gameObject.SetActive(true); // Tap button activated photoReview.PreventClicksPanel.transform.gameObject.SetActive(false); // User cannot click anything until table is loaded } } // getAllTables... if (dataContainer.QueryType == Drive.QueryType.getAllTables) { string rawJSon = dataContainer.payload; // The response for this query is a json list of objects that hold two fields: // * objType: the table name (we use for identifying the type). // * payload: the contents of the table in json format. Drive.DataContainer[] tables = JsonHelper.ArrayFromJson <Drive.DataContainer>(rawJSon); // Once we get the list of tables, we could use the objTypes to know the type and convert json to specific objects. // On this example, we will just dump all content to the console, sorted by table name. string logMsg = "<color=yellow>All data tables retrieved from the cloud.\n</color>"; for (int i = 0; i < tables.Length; i++) { logMsg += "\n<color=blue>Table Name: " + tables[i].objType + "</color>\n" + tables[i].payload + "\n"; } Debug.Log(logMsg); } // getObjectsByField... if (dataContainer.QueryType == Drive.QueryType.getObjectsByField) { string rawJSon = dataContainer.payload; Debug.Log(rawJSon); // Check if the type is correct. if (string.Compare(dataContainer.objType, AllPhotosSheet) == 0) { // Parse from json to the desired object type. PhotoInfo[] photos = JsonHelper.ArrayFromJson <PhotoInfo>(rawJSon); for (int i = 0; i < photos.Length; i++) //TODO: Delete this after debug { Debug.Log("<color=yellow>Object retrieved from the cloud and parsed: \n</color>" + "filename: " + photos[i].filename + "\n" + "photo_uid: " + photos[i].photo_uid + "\n" + "dropbox_path: " + photos[i].dropbox_path + "\n" + "date: " + photos[i].date + "\n" + "location: " + photos[i].location + "\n" + "comments: " + photos[i].comments + "\n" + "favorite: " + photos[i].favorite + "\n" + "forget_photo: " + photos[i].forget_photo + "\n" + "file_type: " + photos[i].location + "\n" + "audio_file_path: " + photos[i].audio_file_path + "\n" + "last_edited_date: " + photos[i].last_edited_date + "\n" + "last_editor_name: " + photos[i].last_editor_name + "\n"); } } } }
// Processes the data received from the cloud. public void HandleDriveResponse(Drive.DataContainer dataContainer) { Debug.Log(dataContainer.msg); // First check the type of answer. if (dataContainer.QueryType == Drive.QueryType.getObjectsByField) { string rawJSon = dataContainer.payload; Debug.Log(rawJSon); // Check if the type is correct. if (string.Compare(dataContainer.objType, _tableName) == 0) { // Parse from json to the desired object type. PlayerInfo[] players = JsonHelper.ArrayFromJson <PlayerInfo>(rawJSon); for (int i = 0; i < players.Length; i++) { _playerData = players[i]; Debug.Log("<color=yellow>Object retrieved from the cloud and parsed: \n</color>" + "Name: " + _playerData.name + "\n" + "Level: " + _playerData.level + "\n" + "Health: " + _playerData.health + "\n" + "Role: " + _playerData.role + "\n"); } } } // First check the type of answer. if (dataContainer.QueryType == Drive.QueryType.getTable) { string rawJSon = dataContainer.payload; Debug.Log(rawJSon); // Check if the type is correct. if (string.Compare(dataContainer.objType, _tableName) == 0) { // Parse from json to the desired object type. PlayerInfo[] players = JsonHelper.ArrayFromJson <PlayerInfo>(rawJSon); string logMsg = "<color=yellow>" + players.Length.ToString() + " objects retrieved from the cloud and parsed:</color>"; for (int i = 0; i < players.Length; i++) { logMsg += "\n" + "<color=blue>Name: " + players[i].name + "</color>\n" + "Level: " + players[i].level + "\n" + "Health: " + players[i].health + "\n" + "Role: " + players[i].role + "\n"; } Debug.Log(logMsg); } } // First check the type of answer. if (dataContainer.QueryType == Drive.QueryType.getAllTables) { string rawJSon = dataContainer.payload; // The response for this query is a json list of objects that hold tow fields: // * objType: the table name (we use for identifying the type). // * payload: the contents of the table in json format. Drive.DataContainer[] tables = JsonHelper.ArrayFromJson <Drive.DataContainer>(rawJSon); // Once we get the list of tables, we could use the objTypes to know the type and convert json to specific objects. // On this example, we will just dump all content to the console, sorted by table name. string logMsg = "<color=yellow>All data tables retrieved from the cloud.\n</color>"; for (int i = 0; i < tables.Length; i++) { logMsg += "\n<color=blue>Table Name: " + tables[i].objType + "</color>\n" + tables[i].payload + "\n"; } Debug.Log(logMsg); } }