Quantcast
Channel: Questions in topic: "get"
Viewing all articles
Browse latest Browse all 215

problem updating info to data base

$
0
0
Hi, I have a problem which I mange to update the data *but!* the update is done regardless of the user info and only after I clicked once. ill explain I want to add to the user with a name he typed down 2 gems, however with the code I wrote the player get 2 gems every time he press down "update", but he starts from 0 every time I initialize the game/ my code: using Proyecto26; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class gameManagerServer : MonoBehaviour { public static string username; public static int gems; public InputField name2 ; user user1 = new user(); public void onClickUpdate() { username = name2.text.ToString(); RetrieveFromDataBase(); user1 = new user(); if (username != "") // nessecery, otherwise can delete all data. { RestClient.Put("https://save-the-space.firebaseio.com/" + username + ".json", user1); } else { Debug.Log("cannot update user with emepty username"); } } private void RetrieveFromDataBase() { RestClient.Get("https://save-the-space.firebaseio.com/" + username + ".json").Then(response => { user1 = response; Debug.Log(user1); // user1.gems = response.gems; // user1.username = response.username; upadteScore(); }); } private void upadteScore() { // gems = user1.gems; gems++; gems++; Debug.Log(gems); } } (I'm using "Rest Client for unity" which I imported from the asset store.) thanks!

Viewing all articles
Browse latest Browse all 215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>