public void SetEachPlantDataInDbAfterCreatingContract() { plant = new SinglePlantThree(); plant.ContractID = ContractID; plant.isPlantInContract = true; plant.isPlantPlanted = true; plant.isDroneAssigned = false; plant.FieldID = id; string ToJson = JsonUtility.ToJson(plant); reference.Child("USERS").Child(LogInAndRegister.Instance.UserName).Child("GAMESPACE").Child("CONTRACT" + plant.ContractID).Child("PLANTS").Child("PLANT" + plant.FieldID).SetRawJsonValueAsync(ToJson); }
public void GetDBDataForPlant() { FirebaseDatabase.DefaultInstance .GetReference("USERS").Child(LogInAndRegister.Instance.UserName).Child("GAMESPACE").Child("CONTRACT" + ContractID).Child("PLANTS").Child("PLANT" + id) .GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; //Debug.Log("data for plant " + snapshot.GetRawJsonValue()); plant = JsonUtility.FromJson <SinglePlantThree>(snapshot.GetRawJsonValue()); } }); }