/// <summary> /// Start this instance. /// </summary> /// <returns>A Unity coroutine IEnumerator.</returns> public IEnumerator Start() { nArray = new MoBackArray(); MoBackRow newRow1 = new MoBackRow("TestMoback"); // Create a new row for a new user with a score of 0 to start. newRow1.SetValue("Name", "MoBackUser"); newRow1.SetValue("Score", 0); // Send the data to the table and wait for a response. MoBackRequest response = newRow1.Save(); yield return(response.Run()); // If the response to the request is an error, output the error details. if (response.State == MoBackRequest.RequestState.ERROR) { Debug.LogError(response.errorDetails); } if (menuHandler == null) { menuHandler = FindObjectOfType <DemoMenuHandler>(); } }
/// <summary> /// Raises the add item button click event. /// </summary> private void OnAddItemButtonClick() { MoBackRow t = new MoBackRow(ChildRelationTableName); t.SetValue(ItemTypeColumn, childInput.text); items.Add(t); Display(childInput.text + " has been added to child array"); childInput.text = string.Empty; if (items.Count >= 1) { createRelationButton.gameObject.SetActive(true); } }
/// <summary> /// Saves the name of the player. /// </summary> /// <returns>The player name.</returns> private IEnumerator SavePlayerName() { playerRow.SetValue("PlayerName", parentInput.text); MoBackRequest savePlayerInfoRequest = playerRow.Save(); yield return(savePlayerInfoRequest.Run()); if (savePlayerInfoRequest.State != MoBackRequest.RequestState.COMPLETED) { Debug.LogError("Can't save player info " + savePlayerInfoRequest.errorDetails.Message); yield break; } else { ChangeScene(inputItemScene); Display(parentInput.text + " saved to " + DemoRelationTableName + "Table"); } }
/// <summary> /// Raises the add button click event. /// </summary> private void OnAddButtonClick() { addButton.enabled = false; if (!string.IsNullOrEmpty(valueInput.text)) { MoBackRow row = new MoBackRow(DemoBatchTableName); row.SetValue("Value", valueInput.text.ToString()); demoBatchObjects.Add(row); Display(valueInput.text + " Added successfully "); valueInput.text = string.Empty; } else { Display("Field Cannot be Blank"); } addButton.enabled = true; }
IEnumerator UpdateRow() { MoBackRow newRow = new MoBackRow("PlayersData"); newRow.SetValue("IDcode", currentID); newRow.SetValue("aValue", GameObject.Find("Main").GetComponent <scene2script>().userData.a); newRow.SetValue("bValue", GameObject.Find("Main").GetComponent <scene2script>().userData.b); newRow.SetValue("xValue", GameObject.Find("Main").GetComponent <scene2script>().userData.x); newRow.SetValue("yValue", GameObject.Find("Main").GetComponent <scene2script>().userData.y); newRow.SetValue("maxScene", maxScene); MoBackRequest response = newRow.Save(); yield return(response.Run()); }
/// <summary> /// Updates an existing row with a new score and notifies the user when successful. /// </summary> /// <returns>A Unity coroutine IEnumerator.</returns> /// <param name="score">Score to submit.</param> public IEnumerator SubmitScore(int score) { // Create a new table called "TestMoBack" if it hasn't already been created; otherwise, specify which table you want to work with. table = new MoBackTableInterface("TestMoback"); // Send a request for data to the server with a specific set of parameters. MoBackRequest <List <MoBackRow> > tableContentsFetch = table.GetRows(new MoBackRequestParameters().EqualTo("Name", "MoBackUser")); yield return(tableContentsFetch.Run()); // Once the request has been completed, manipulate the fetched data. if (tableContentsFetch.State == MoBackRequest.RequestState.COMPLETED) { List <MoBackRow> rows = tableContentsFetch.ResponseValue; // Update the last item in the table to a new score and send to the server. MoBackRow newRow = rows[rows.Count - 1]; newRow.SetValue("Score", score); MoBackRequest response = newRow.Save(); // Wait for a response before displaying that the request was successful. yield return(response.Run()); if (response.State == MoBackRequest.RequestState.COMPLETED) { menuHandler.Display("Score submitted successfully."); } else { menuHandler.Display("Request was not successful. Please double check your app ID and/or environment key."); // Display an error should one occur. Debug.Log(response.errorDetails); } } else { // Display an error should one occur. Debug.Log(tableContentsFetch.errorDetails); } }