public void LeaveRoomWhenPlaying() { //Oyun sahnesinden ayrılırken oyuncu odadan çıkarılır. roomsRef.Child(roomName).GetValueAsync().ContinueWith(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { //Oyuncunun odadaki oyun sahnesine ait değişkenleri Databaseden kaldırılır. RoomData joinedRoom = JsonUtility.FromJson <RoomData>(snapshot.GetRawJsonValue()); roomsRef.Child(joinedRoom.roomName).Child("RoomUsers").Child(auth.CurrentUser.UserId).RemoveValueAsync(); roomsRef.Child(joinedRoom.roomName).Child("GameScene").Child(auth.CurrentUser.UserId).RemoveValueAsync(); roomsRef.Child(joinedRoom.roomName).Child("GameSceneDistances").Child(auth.CurrentUser.UserId).RemoveValueAsync(); //Oyuncu odadan çıkarıldıktan sonra gerekli kontroller tekrardan yapılır. if (joinedRoom.roomLeadId == auth.CurrentUser.UserId) { joinedRoom.roomLeadId = null; roomsRef.Child(joinedRoom.roomName).Child("roomLeadId").SetValueAsync(joinedRoom.roomLeadId); } joinedRoom.currentPlayerCount--; if (joinedRoom.currentPlayerCount > 0) { roomsRef.Child(joinedRoom.roomName).Child("currentPlayerCount").SetValueAsync(joinedRoom.currentPlayerCount); } else { roomsRef.Child(joinedRoom.roomName).RemoveValueAsync(); } } }); }
void RetreiveData() { FirebaseDatabase.DefaultInstance .GetReference("USERS") .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; Debug.Log(snapshot.GetRawJsonValue()); if (snapshot.GetRawJsonValue() == null) { MasterUserManager.Instance.MasterContractID = 0; PlayerPrefs.SetInt("mstrcontractcounter", MasterUserManager.Instance.MasterContractID); MasterUserManager.Instance.MasterContractID = PlayerPrefs.GetInt("mstrcontractcounter", MasterUserManager.Instance.MasterContractID); Debug.Log("mstrcounter now is " + MasterUserManager.Instance.MasterContractID); } // Do something with snapshot... } }); }
public void JoinRoom() { if (selectedRoomName != null && selectedRoomName != "") { //Bu değişkene ilgili değer listelenen odalarda bulunan butona tıklandığında atanmaydı. roomsRef.Child(selectedRoomName).GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { RoomData joiningRoom = JsonUtility.FromJson <RoomData>(snapshot.GetRawJsonValue()); //Odanın kapasitesi dolu ise uyarı verilir. Değil ise odaya katılınır ve yeni oyuncu odaya eklenir. if (joiningRoom.currentPlayerCount < joiningRoom.maxPlayer) { joinRoomMenu.SetActive(false); NewRoomUser(joiningRoom); } else { exceptionText.text = "This room is full."; } } else { exceptionText.text = "This room may have been deleted. Please refresh table."; } }); } }
public void GetValueAsync <T>(string referencePath, System.Action <T> modelUpdatedEvent) { // get the quiz FirebaseDatabase.DefaultInstance .GetReference(referencePath) .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.LogError(task.Exception.ToString()); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; Debug.Log("snapshot.GetRawJsonValue: " + snapshot.GetRawJsonValue()); modelUpdatedEvent(snapshot != null ? JsonUtility.FromJson <T>(snapshot.GetRawJsonValue()) : default(T)); } else if (task.IsCanceled) { // Handle the error... Debug.LogWarning("GetValueAsync cancelled."); modelUpdatedEvent(default(T)); } }); }
private void OnMatchDetailChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } DataSnapshot snapshot = args.Snapshot; if (snapshot == null || !snapshot.HasChildren) { Debug.Log("null"); } if (matchDetailList.ContainsKey(snapshot.Key)) //Updating existing match { Debug.Log("Updating match from " + snapshot.GetRawJsonValue()); matchDetailList[snapshot.Key].UpdateMatch(snapshot); } else //Creating new Match { Debug.Log("Creating new match from " + snapshot.GetRawJsonValue()); Match newMatch = new Match(snapshot, UserId); matchDetailList[snapshot.Key] = newMatch; } if (_userMatchcallback != null && matchList.Count == matchDetailList.Count) { _userMatchcallback(matchDetailList); } }
private void Start() { multiplayerManagerClass = this; //Aktif oyuncu sahneye bağlandığı sırada Database'e kendi verilerini gönderir ve kostüm değişikliği uygulanır. userDataRef.Child(auth.CurrentUser.UserId).GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { UserData me = JsonUtility.FromJson <UserData>(snapshot.GetRawJsonValue()); Player playerMe = new Player(); playerMe.userId = auth.CurrentUser.UserId; playerMe.nick = me.nick; playerMe.skin = me.skin; roomRef.Child("GameScene").Child(auth.CurrentUser.UserId).SetRawJsonValueAsync(JsonUtility.ToJson(playerMe)); playerObject.GetComponent <Renderer>().material.color = me.skin; } }); //Aktif oyuncunun bulunduğu odadaki oyuna bağlanacak olan oyuncu sayısı ilgili değişkene atanır. roomRef.GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { RoomData room = JsonUtility.FromJson <RoomData>(snapshot.GetRawJsonValue()); playingPlayerCount = room.playingPlayerCount; } }); }
public void Yes() { //Top satın alma sırasında karşımıza çıkan "Are you sure?" menüsündeki "Yes" butouna tanımlanmıştır. userDataRef.Child(auth.CurrentUser.UserId).GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { //Aktif olan kullanıcının envanterine ilgili top dahil edilir. UserData user = JsonUtility.FromJson <UserData>(snapshot.GetRawJsonValue()); user.inventory[user.inventoryLength] = buyingColor; user.inventoryLength++; //Aktif olan kullanıcının hesabından BallPrice düşülür. if (buyingMoneyType == MoneyType.Coin) { user.coin -= buyingPrice; } else { user.crystal -= buyingPrice; } //Bu işlemlerden sonra kullanıcıya ait değişkenler Database'e ve menüdeki textlere yazılır. userDataRef.Child(auth.CurrentUser.UserId).SetRawJsonValueAsync(JsonUtility.ToJson(user)); UpdateButtons(user.inventory, user.inventoryLength, user.skin); crystalText.text = user.crystal.ToString(); coinText.text = user.coin.ToString(); } }); SureMenu.SetActive(false); }
public void getDataFromFirebase( ) { reference.Child("users").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { print("ERRO: Não foi possive listar dados."); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; print("snapshot.GetRawJsonValue: " + snapshot.GetRawJsonValue()); User[] user = jsonToUser(snapshot.GetRawJsonValue()); print("USERS: " + user.Length); string temp = ""; for (int c = 0; c < user.Length; c++) { temp += "[" + (c + 1) + "º] " + user[c].email + "\t" + user[c].username + System.Environment.NewLine; } ui.setLeaders(temp); } }); }
//서치 유저... public void SearchUser(string userId) { FirebaseDatabase.DefaultInstance.RootReference.GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { Debug.Log("Failed"); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot.HasChild("users")) { FirebaseDatabase.DefaultInstance.GetReference("users").GetValueAsync().ContinueWith(task2 => { if (task2.IsFaulted) { Debug.Log("Failed"); } else if (task2.IsCompleted) { Debug.Log("서치들어감"); DataSnapshot snapshot2 = task2.Result; Debug.Log(snapshot2.GetRawJsonValue().Contains(userId)); Debug.Log(snapshot2.GetRawJsonValue()); Debug.Log(snapshot2.Value.ToString()); if (snapshot2.Child(userId).Exists) { UserDataManager.Instance.isUserfirst = false; Debug.Log("User find " + userId); UserDataManager.Instance.GetUser(); return; } else { UserDataManager.Instance.isUserfirst = true; Debug.Log("Can't access user"); Debug.Log("새로운 유저 등록 !!"); UserDataManager.Instance.AddUser(); return; } } }); } else { UserDataManager.Instance.isUserfirst = true; Debug.Log("Can't access user"); Debug.Log("새로운 유저 등록 !!"); UserDataManager.Instance.AddUser(); } } }); Debug.Log("써치끝"); }
private void OnCollectionDataChanged(EventData e) { Debug.Log("Collection data changed! Updating UI..."); DataSnapshot dataList = (DataSnapshot)e.Data["box_list"]; Debug.Log(dataList.GetRawJsonValue()); CollectionData collection = JsonUtility.FromJson <CollectionData>(dataList.GetRawJsonValue()); BoxList.UpdateList(collection); }
private void GetMessagesFromDatabase() { //Mesajlar Database'den çekilir. roomsRef.Child(RoomManager.roomManagerClass.roomName).Child("Messages").GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { //"Messages" ağacının altındaki liste ilgili metoda gönderilir. Messages message = JsonUtility.FromJson <Messages>(snapshot.GetRawJsonValue()); SendMessagesToChat(message); } }); }
public void Ready() { //Bu metot odada bulunan "Ready" butonuna tanımlanmıştır. roomsRef.Child(roomName).GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { RoomData joinedRoom = JsonUtility.FromJson <RoomData>(snapshot.GetRawJsonValue()); roomsRef.Child(roomName).Child("RoomUsers").GetValueAsync().ContinueWithOnMainThread(childTask => { DataSnapshot childSnapshot = childTask.Result; if (childSnapshot.GetRawJsonValue() != null) { int index = 0; foreach (DataSnapshot ds in childSnapshot.Children) { //Odada bulunan oyuncular arasından aktif oyuncunun ID'sine göre Database'de oyuncunun "ready" değişkeni güncellenir. RoomData.RoomUsers roomUser = JsonUtility.FromJson <RoomData.RoomUsers>(ds.GetRawJsonValue()); if (roomUser.userId == auth.CurrentUser.UserId) { playerRows.transform.GetChild(index).transform.GetChild(1).transform.gameObject.SetActive(!roomUser.ready); roomUser.ready = !roomUser.ready; canLeave = !roomUser.ready; roomsRef.Child(joinedRoom.roomName).Child("RoomUsers").Child(roomUser.userId).Child("ready").SetValueAsync(roomUser.ready); //Eğer ki oyuncu hazır durumuna geldiyse odaya ait hazır oyuncu sayısı ve buton rengi güncellenir. if (roomUser.ready) { joinedRoom.readyPlayerCount++; readyButton.GetComponent <Image>().color = Color.green; } //Eğer ki oyuncu hazır durumundan çıktıysa odaya ait hazır oyuncu sayısı ve buton rengi güncellenir. else { joinedRoom.readyPlayerCount--; readyButton.GetComponent <Image>().color = Color.white; } roomsRef.Child(joinedRoom.roomName).Child("readyPlayerCount").SetValueAsync(joinedRoom.readyPlayerCount); break; } index++; } } }); } }); }
public void LeaveRoom() { if (canLeave) { //Oyuncu odadan ayrılabilirse ilgili menüler SetActive edilir. roomMenu.SetActive(false); joinRoomMenu.SetActive(true); readyButtonObject.SetActive(true); startButtonObject.SetActive(false); inRoom = false; MessageManager.leftRoom = true; roomsRef.Child(roomName).GetValueAsync().ContinueWithOnMainThread(task => { DataSnapshot snapshot = task.Result; if (snapshot.GetRawJsonValue() != null) { //Ayrılınan odanın "RoomUsers" ağacından aktif kullanıcı kaldırılır. RoomData joinedRoom = JsonUtility.FromJson <RoomData>(snapshot.GetRawJsonValue()); roomsRef.Child(joinedRoom.roomName).Child("RoomUsers").Child(auth.CurrentUser.UserId).RemoveValueAsync(); RefReshTable(); //Eğer ki kullanıcı oda lideri ise Database'deki oda lideri sıfırlanır. if (joinedRoom.roomLeadId == auth.CurrentUser.UserId) { joinedRoom.roomLeadId = null; roomsRef.Child(joinedRoom.roomName).Child("roomLeadId").SetValueAsync(joinedRoom.roomLeadId); } //Odada bulunan oyuncu sayısı 1 azaltılır ve odada oyuncu kalmadıysa oda kapatılır. joinedRoom.currentPlayerCount--; if (joinedRoom.currentPlayerCount > 0) { roomsRef.Child(joinedRoom.roomName).Child("currentPlayerCount").SetValueAsync(joinedRoom.currentPlayerCount); } else { roomsRef.Child(joinedRoom.roomName).RemoveValueAsync(); } } }); } //Oyuncu hazır durumunda iken odadan ayrılamaz. else { exceptionText.text = "You can not leave when ready!"; } }
private void LoadPlayerData(string UserId) { DataSnapshot snapshot = null; string ConvertSnapShot = null; Debug.Log("LoadingPlayer"); FirebaseAuth auth = FirebaseAuth.DefaultInstance; string uid = auth.CurrentUser.UserId; FirebaseDatabase.DefaultInstance.GetReferenceFromUrl("https://crazybird-2d.firebaseio.com/users/" + uid).Child("PlayerStats").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { Debug.Log("User Not Found"); // Handle the error... } if (task.IsCompleted) { snapshot = task.Result; ConvertSnapShot = snapshot.GetRawJsonValue(); Debug.Log("snapshot Taken"); PlayerStats s = JsonUtility.FromJson <PlayerStats>(ConvertSnapShot); _stats.Cash = s.Cash; _stats.Gems = s.Gems; _stats.PlayerLevel = s.PlayerLevel; _stats.AttackSpeedLevel = s.AttackSpeedLevel; _stats.SpeedLevel = s.SpeedLevel; Debug.Log("Cash = " + _stats.Cash); loaded = true; } }); }
private void FetchUserData(string firebaseUserId) { //Debug.Log("FetchUserData " + firebaseUserId); FirebaseDatabase.DefaultInstance.GetReference("Users/" + firebaseUserId).GetValueAsync().ContinueWithOnMainThread(task => { if (task.IsFaulted || task.IsCanceled) { fetchCallback(null); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot != null && snapshot.Value != null) { string jsonString = snapshot.GetRawJsonValue(); UserInfo info = JsonUtility.FromJson <UserInfo>(jsonString); fetchCallback(info); Debug.Log("UserInfo: " + jsonString); } else { fetchCallback(null); Debug.Log("UserInfo not found"); } } }); }
public void LoadLevelData() { FirebaseDatabase.DefaultInstance.GetReference(DatabaseConstants.LEVEL_KEY).GetValueAsync() .ContinueWithOnMainThread(task => { if (task.IsFaulted) { Debug.Log("couldn't load level from database"); } else if (task.IsCompleted) { // using this boolean for simple reset of our online database if (!_sendLocalDatabaseToServer) { DataSnapshot snapshot = task.Result; LevelData levelData = JsonUtility.FromJson <LevelData>(snapshot.GetRawJsonValue()); Debug.Log("Level Loaded"); OnLevelLoaded.Invoke(levelData); } else { SendLocalDatabaseToServer(); } } }); }
public async Task <UserResources> GetUserResources(UserDB pUser) { if (DatosFirebaseRTHelper.Instance.isInit == false) { return(null); } UserResources userResources = new UserResources(); DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.UsersResourcesTable) .Child(pUser.Name.ToLower()).KeepSynced(true); await DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.UsersResourcesTable) .Child(pUser.Name.ToLower()) .Child(resources).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { //Debug.Log("NoChild"); // Handle the error... userResources = null; } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; userResources = JsonUtility.FromJson <UserResources>(snapshot.GetRawJsonValue()); } }); return(userResources); }
public void LoadData() { FirebaseDatabase.DefaultInstance.GetReferenceFromUrl(DATA_URL).GetValueAsync() .ContinueWith((task => { if (task.IsCanceled) { } if (task.IsFaulted) { } if (task.IsCompleted) { DataSnapshot snapshot = task.Result; string playerData = snapshot.GetRawJsonValue(); //Player m = JsonUtility.FromJson<Player>(playerData); foreach (var child in snapshot.Children) { string t = child.GetRawJsonValue(); Player extractedData = JsonUtility.FromJson <Player>(t); print("The Player is: " + extractedData.Username); print("The Player's pass is: " + extractedData.Password); } } })); }
private void UserDataInitate(string userID) { mDatabaseRef.Child("users").OrderByKey().EqualTo(userID).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { Debug.Log(task); // Handle the error... } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot.Value == null) { } else { JSONNode N = JSON.Parse(snapshot.GetRawJsonValue()); if (N.Count != 0) { User user = new User(N[userID]["userID"], N[userID]["userNickName"]); currentUser = user; } } newUserSet = true; } }); }
private async static Task <LevelProgress[]> FetchDataFromFireBase() { LevelProgress[] result = null; await FireBaseDatabase.Database.Child(FireBaseSavePaths.PlayerProgressLocation()) .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { } else if (task.IsCompleted) { try { DataSnapshot snapshot = task.Result; string info = snapshot?.GetRawJsonValue()?.ToString(); if (info != null) { result = JsonHelper.FromJson <LevelProgress>(info); } } catch (Exception ex) { Debug.LogError(ex); } } }); return(result); }
/// <summary> /// retrieve user's progile information /// </summary> /// <param name="callback"></param> /// <exception cref="System.ArgumentNullException">Thrown when callback not provided</exception> public void getUserInfo(Action <User, string> callback) { if (callback == null) { throw new ArgumentNullException("callback is not provided"); } string uid = getFirebaseUser().UserId; _db.RootReference.Child(ROOT_USER).Child(uid).GetValueAsync().ContinueWithOnMainThread(task => { string message = readError(task); if (message != null) { callback(null, message); return; } if (task.IsCompleted) { message = "task is success"; DataSnapshot snapshot = task.Result; User user = JsonConvert.DeserializeObject <User>(snapshot.GetRawJsonValue()); user.id = uid; Debug.Log(user.ToString()); callback(user, message); } }); }
void SaveNewDataToFileFromDatabase(DataSnapshot snapshot) { ContactPointCollection contactPoints = new ContactPointCollection(); JsonUtility.FromJsonOverwrite(snapshot.GetRawJsonValue(), contactPoints); TriviaSaveLoadSystem.SaveContactPoints(contactPoints); }
public async Task <CardDataLimit> GetCardsLimitData(UserDB pUser) { if (DatosFirebaseRTHelper.Instance.isInit == false) { return(null); } CardDataLimit cardsLimitData = new CardDataLimit(); DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.CardsLimitDataTable).KeepSynced(true); await DatosFirebaseRTHelper.Instance.reference.Child(DatosFirebaseRTHelper.Instance.CardsLimitDataTable).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { //Debug.Log("NoChild"); // Handle the error... } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; cardsLimitData = JsonUtility.FromJson <CardDataLimit>(snapshot.GetRawJsonValue()); FbCardDataLimitUpdater cLimitUpdt = new FbCardDataLimitUpdater(); cLimitUpdt.UpdateLastUserCardLimitDataDownloadTimestamp(pUser); } }); return(cardsLimitData); }
void getScheduleData() { reference.GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.Log("error fetching data"); } else if (task.IsCompleted) { // getting schedules for a particular user. DataSnapshot snapshot = task.Result.Child(dbDetails.getTourDBName()); string str = snapshot.GetRawJsonValue(); JObject jsonLocation = JObject.Parse(str); IList <string> keys = jsonLocation.Properties().Select(p => p.Name).ToList(); foreach (string key in keys) { Debug.Log(key); this.schedules.Add(new Department(key)); } } }); }
public async Task <long> GetLastUserCardCollectioModificationTimestampUser(string name) { if (DatosFirebaseRTHelper.Instance.isInit == false) { //Debug.Log("FIREBASE NOT INITIALIZE"); return(0); } //FirebaseDatabase.DefaultInstance.GetReference("Users").Child(name).KeepSynced(true); FbUserChecker fbUser = new FbUserChecker(); DataSnapshot userNameExist = await fbUser.UserDataSnapshotExistByName(name.ToLower()); long utcLastUCCDownload = 0; if (userNameExist != null) { if (userNameExist.Exists) { UserDB user = JsonUtility.FromJson <UserDB>(userNameExist.GetRawJsonValue()); utcLastUCCDownload = user.utcLastModificationUserCollectionUnix; //Debug.Log("user.MAcc " + user.Salt); } } return(utcLastUCCDownload); }
public void GetListValueAsync <T>(string referencePath, System.Action <List <T> > modelUpdatedEvent) { // get the quiz FirebaseDatabase.DefaultInstance .GetReference(referencePath) .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.LogError(task.Exception.ToString()); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; if (snapshot != null) { string newJson = "{\"dataList\": " + snapshot.GetRawJsonValue() + "}"; GenericListWrapper <T> listWrapper = JsonUtility.FromJson <GenericListWrapper <T> >(newJson); modelUpdatedEvent(listWrapper.dataList); } else { modelUpdatedEvent(new List <T>()); } } else if (task.IsCanceled) { Debug.Log("GetListValueAsync Cancelled"); } }); }
//To show all the reviews related to the particular product public void show() { char[] splitChar = { '\n' }; string[] list = mTargetMetadata.Split(splitChar); string tag = list [0]; FirebaseDatabase.DefaultInstance .GetReference("Rows") .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { Debug.Log("Error in fetching database"); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; //Debug.Log( snapshot.GetRawJsonValue().ToString() ) ; string res = snapshot.GetRawJsonValue().ToString(); var N = JSON.Parse(res); var rows = N ["Rows"].Children; int j = 1; string ans = "Some reviews.\n"; foreach (var row in rows) { string tag1 = row["tag"], content = row["content"]; if (tag.Equals(tag1)) { ans = ans + j.ToString() + ". " + content + "\n"; } j++; } reviews.text = ans; } }); }
protected virtual void InitializeFirebase() { //This is how you get a reference point to the database DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("Test2"); //This is how you write a json to a value //Note the Original value will be overwritten of you dont add it in the update reference.SetRawJsonValueAsync("{\"Iets2\":\"Niets2\", \"NogIets\":\"nooit\"}").ContinueWithOnMainThread(task => { if (task.Exception != null) { Debug.Log("mislukt!"); } else if (task.IsCompleted) { Debug.Log("transaction complete."); } }); //This makes an unique identifier DatabaseReference reference2 = reference.Push(); //This is how you query values reference.GetValueAsync().ContinueWithOnMainThread(task2 => { DataSnapshot snapshot = task2.Result; Debug.Log(snapshot.Key); Debug.Log(snapshot.GetRawJsonValue().ToString()); }); }
public void CheckDatabaseVersion() { #if !UNITY_EDITOR EnableLoadingIndicator(); string currentDatabaseVersion = PlayerPrefs.GetString("database_version"); FirebaseDatabase.DefaultInstance .GetReference("database_version") .GetValueAsync().ContinueWith(task => { if (task.IsCompleted) { DataSnapshot snapshot = task.Result; string verNumberString = snapshot.GetRawJsonValue(); if (verNumberString != currentDatabaseVersion) { TriviaSaveLoadSystem.DeleteData(); PlayerPrefs.SetString("database_version", verNumberString); //TODO: Implement a function that checks current selected language, possible to do with the localization manager or playerprefabs. DownloadWithNewLanguage(); } else { myPointData = TriviaSaveLoadSystem.LoadContactPoints(); if (myPointData != null) { //trivia up to date SpawnUpToDatePanel(); } } } }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); #endif }
// Récupération de l'exercice 1.2 void HandleValueChanged3(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } DataSnapshot snapshot = args.Snapshot; exo = JsonUtility.FromJson <Exercice>(snapshot.GetRawJsonValue()); // Mise à jour de la valeur des selects : string[] nom_audio = { "1_2", "2_3", "3_2", "4_5", "5_6", "5_7", "6_5", "7_5", "7_9", "8_3" }; for (int i = 0; i < nom_audio.Length; i++) { if (nom_audio[i].Equals(exo.boutonSon1)) { drop121.value = i; } if (nom_audio[i].Equals(exo.boutonSon2)) { drop122.value = i; } if (nom_audio[i].Equals(exo.boutonSon3)) { drop123.value = i; } if (nom_audio[i].Equals(exo.boutonSon4)) { drop124.value = i; } } }