private void EditorUpdate() { while (!_www.isDone) { _elapsedTime = EditorApplication.timeSinceStartup - _startTime; if (_elapsedTime >= connectionData.timeOutLimit) { Drive.ProcessResponse("TIME_OUT", (float)_elapsedTime); EditorApplication.update -= EditorUpdate; } return; } if (_www.isNetworkError) { Drive.ProcessResponse("Connection error after " + _elapsedTime.ToString() + " seconds: " + _www.error, (float)_elapsedTime); return; } Drive.ProcessResponse(_www.downloadHandler.text, (float)_elapsedTime); EditorApplication.update -= EditorUpdate; }
public void CreateConsoleLogTable() { var logFields = Enum.GetNames(typeof(TABLE_HEADERS)); Drive.CreateTable(logFields, TABLE_NAME); }
private void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, 600, 1000)); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.BeginVertical(); GUILayout.Label("This example will load an image into a texture from either a local file or a screenshot," + " and enable user to upload the image to Drive as JPG or PNG file, as well as later retrieve the image back by its reported Drive id.", GUILayout.MaxWidth(600f)); GUILayout.Space(10f); if (GUILayout.Button("Load PNG from local file", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { LoadPNGFromFile(Application.dataPath + _imagePath); } if (GUILayout.Button("Take Screenshot", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { TakeScreenshot(); } GUILayout.Space(10f); if (GUILayout.Button("Save Image to Cloud as PNG", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { if (_text2d == null) { Debug.Log("Cannot upload image: please load a file or take a screenshot first."); } else { Drive.CreateImageFile(_text2d, "TextureFile", true); } } if (GUILayout.Button("Save Image to Cloud as JPG", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { if (_text2d == null) { Debug.Log("Cannot upload image: please load a file or take a screenshot first."); } else { Drive.CreateImageFile(_text2d, "TextureFile", false, 90, null, null, true); } } GUILayout.Space(10f); GUILayout.Label("Google Drive file id:"); _cloudFileID = GUILayout.TextField(_cloudFileID, GUILayout.MaxWidth(200f)); if (GUILayout.Button("Get From Cloud", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { if (string.IsNullOrEmpty(_cloudFileID)) { Debug.Log("Cannot retrieve a file: please provide an id for the image file on Google Drive."); } else { Drive.GetImageFile(_cloudFileID); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); if (_text2d != null) { GUI.DrawTexture(_texturePos, _text2d); } }
private void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, 600, 1000)); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.BeginVertical(); GUILayout.Label("This example shows how to use the custom login system, which purpuse is to manage a session context" + " in case its needed instead of stateless individual queries with password." + "\n\nNote that upon login, 'Use Session Context' on the ConnectionData asset is set to true.", GUILayout.MaxWidth(600f)); GUILayout.Space(10f); GUILayout.Label("If you dont have a table created on the spreadsheet for this purpose, use this button:"); if (GUILayout.Button("Create Login Data Table", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { Drive.CreateCredentialsTable(credentialsTableName); _waitingForServerResponse = true; } GUILayout.Space(20f); GUILayout.BeginHorizontal(); GUILayout.BeginVertical("Login", GUI.skin.box, GUILayout.MaxWidth(230)); GUILayout.Space(20f); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.BeginVertical(); GUILayout.Label("Username:"******"Password:"******"•"[0], 25, GUILayout.MaxWidth(200f)); if (GUILayout.Button(_isLoggedIn ? "Logout" : "Login", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { if (_isLoggedIn) { Drive.Logout(); _waitingForServerResponse = true; } else { Drive.Login(_usernameText, _passwdText, credentialsTableName); _waitingForServerResponse = true; } } GUILayout.Space(10f); GUILayout.Label("Last Session: " + _lastLogon); GUILayout.Label("Member since: " + _signupDate); GUILayout.Space(5f); GUILayout.Label("Dont have an account yet?", GUILayout.Width(160)); if (GUILayout.Button("Register", GUILayout.Width(90))) { _showRegistrationForm = true; } GUILayout.Space(10f); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (_showRegistrationForm) { GUILayout.BeginVertical("Register", GUI.skin.box, GUILayout.MaxWidth(230)); GUILayout.Space(20f); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.BeginVertical(); GUILayout.Label("Username:"******"Password:"******"•"[0], 25, GUILayout.MaxWidth(200f)); GUILayout.Label("Email:"); _mailText = GUILayout.TextField(_mailText, GUILayout.MaxWidth(200f)); if (GUILayout.Button("Signup", GUILayout.MinHeight(20f), GUILayout.MaxWidth(200f))) { Drive.Signup(_usernameText, _mailText, _passwdText, "someId", credentialsTableName); _waitingForServerResponse = true; } GUILayout.Space(10f); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (_waitingForServerResponse) { GUILayout.Space(10f); GUILayout.Label(clock); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private void OnGUI() { GUILayout.Space(10f); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.Label("This example will show how to create or retrieve files from Google Drive." + "This example does not cover further posibilities of the API such as deleting files, and creating or deleting folders.", GUILayout.MaxWidth(600f)); GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginVertical("Example 'Player' Object Data:", GUI.skin.box, GUILayout.MaxWidth(230)); GUILayout.Space(20f); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.Label("Player Name:", GUILayout.MaxWidth(100f)); _playerData.name = GUILayout.TextField(_playerData.name, GUILayout.MaxWidth(100f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.Label("Player Level:", GUILayout.MaxWidth(100f)); _playerData.level = int.Parse(GUILayout.TextField(_playerData.level.ToString(), GUILayout.MaxWidth(100f))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.Label("Player Health:", GUILayout.MaxWidth(100f)); _playerData.health = float.Parse(GUILayout.TextField(_playerData.health.ToString(), GUILayout.MaxWidth(100f))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.Label("Player Role:", GUILayout.MaxWidth(100f)); _playerData.role = GUILayout.TextField(_playerData.role, GUILayout.MaxWidth(100f)); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.EndVertical(); GUILayout.BeginArea(new Rect(0, 200, 600, 1000)); GUILayout.BeginHorizontal(); GUILayout.Space(10f); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save data to local binary File", GUILayout.MinHeight(20f), GUILayout.MaxWidth(220f))) { SaveLocalBinaryFile(_filePath + _binaryFileName); } if (GUILayout.Button("Save data to local text File", GUILayout.MinHeight(20f), GUILayout.MaxWidth(220f))) { SaveLocalTextFile(_filePath + _textFileName); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Load data from local Binary File", GUILayout.MinHeight(20f), GUILayout.MaxWidth(220f))) { LoadLocalBinaryFile(_filePath + _binaryFileName); } if (GUILayout.Button("Load data from local Text File", GUILayout.MinHeight(20f), GUILayout.MaxWidth(220f))) { LoadLocalTextFile(_filePath + _textFileName); } GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save Data to Cloud as Binary File", GUILayout.MaxWidth(220f))) { UploadBinaryFile(); } if (GUILayout.Button("Save Data to Cloud as Text File", GUILayout.MaxWidth(220f))) { UploadTextFile(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("Google Drive file id:", GUILayout.MaxWidth(120f)); _cloudFileID = GUILayout.TextField(_cloudFileID, GUILayout.MaxWidth(220f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Get Binary File From Cloud", GUILayout.MinHeight(20f), GUILayout.MaxWidth(220f))) { if (string.IsNullOrEmpty(_cloudFileID)) { Debug.Log("Cannot retrieve a file: please provide an id for the file on Google Drive."); } else { Drive.GetBinaryFile(_cloudFileID); } } if (GUILayout.Button("Get Text File From Cloud", GUILayout.MinHeight(20f), GUILayout.MaxWidth(220f))) { if (string.IsNullOrEmpty(_cloudFileID)) { Debug.Log("Cannot retrieve a file: please provide an id for the file on Google Drive."); } else { Drive.GetTextFile(_cloudFileID); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private void UploadTextFile() { string jsonPlayer = JsonUtility.ToJson(_playerData); Drive.CreateTextFile(jsonPlayer, _textFileName); }
public void GetAllPhotos() { // Get all objects from sheet 'all_photos'. Drive.GetTable(AllPhotosSheet, true); }
public void GetCellValue(string Column, string Row) { Drive.GetCellValue(AllPhotosSheet, Column, Row, true); // return cellValue; // doesn't work: asynchronous process? }
void GetMissingDates() { // Get all objects from sheet 'date_missing'. Drive.GetTable(DateMissingSheet, true); }
public void UpdatePhotoInfo(int currentPhotoTemp, string columnName, string updatedValue) { // We will update an entire row for this photo. Might someday update just the specific cell if faster. // First, construct a row item with current photo data... //int i = photoReview.currentPhoto; int i = currentPhotoTemp; string rowUID = allPhotos[i].filename; // TODO: see if match on filename is much faster than dropbox_path string columnToMatchUID = "filename"; // handle blank date field var dateTempString = ""; if (allPhotos[i].date != "") { //dateTempString = System.DateTime.Parse(allPhotos[i].date).ToString("d"); // de-serialize JSON formatting of date (not needed?) } PhotoInfo _photoData = new PhotoInfo { filename = allPhotos[i].filename, photo_uid = allPhotos[i].photo_uid, dropbox_path = allPhotos[i].dropbox_path, folder = allPhotos[i].folder, date = dateTempString, location = allPhotos[i].location, comments = allPhotos[i].comments, favorite = allPhotos[i].favorite, forget_photo = allPhotos[i].forget_photo, file_type = allPhotos[i].file_type, audio_file_path = allPhotos[i].audio_file_path, last_edited_date = allPhotos[i].last_edited_date, last_editor_name = allPhotos[i].last_editor_name }; // Now substitute in the updatedValue wherever it belongs... if (columnName == "date") { _photoData.date = updatedValue; } if (columnName == "location") { _photoData.location = updatedValue; } if (columnName == "comments") { _photoData.comments = updatedValue; } if (columnName == "favorite") { _photoData.favorite = updatedValue; } if (columnName == "forget_photo") { _photoData.forget_photo = updatedValue; } if (columnName == "audio_file_path") { _photoData.audio_file_path = updatedValue; } // Add last_edited_date and last_editor_name //dateTempString = System.DateTime.Now.ToLongTimeString(); string dateTimeNowString = System.DateTime.Now.ToString("yyyy-MM-dd\\THH:mm:ss\\Z"); _photoData.last_edited_date = dateTimeNowString; _photoData.last_editor_name = photoReview.editorName; string jsonPhotoInfo = JsonUtility.ToJson(_photoData); // Look in the current sheet for a photo with same "dropbox_path", and overwrite with the updated photo data. Debug.Log("*** Started UpdatePhotoInfo() loading at " + System.DateTime.Now.ToLongTimeString()); Debug.Log("AllPhotosSheet = " + AllPhotosSheet); Drive.UpdateObjects(AllPhotosSheet, columnToMatchUID, rowUID, jsonPhotoInfo, false, true); Debug.Log("Updating row " + _photoData.filename); Debug.Log("With this data:\n" + jsonPhotoInfo); }
public void GetAllPhotos() { // Get all objects from current sheet Debug.Log("*** Started GetAllPhotos() loading from '" + AllPhotosSheet + "' at " + System.DateTime.Now.ToLongTimeString()); Drive.GetTable(AllPhotosSheet, true); }