MA1Sensor1.text = FirebaseDatabase .DefaultInstance .GetReference ("MA1") .Child ("Zaehler") .GetValueAsync () //.Result .ToString (); Debug.Log (MA1Sensor1.text);Right now it displays the following RawJson:
{"Program":1,"Zaehler":600}Theoretically, transferring the value from "Program"s Childvalue into variable A and "Zaehler"s Childvalue into variable B should be all I need. Somehow I don't know how.
I would highly appreciate any help
THANKS A LOT
var getTask = FirebaseDatabase
.DefaultInstance
.GetReference ("MA1")
.Child ("Zaehler") .GetValueAsync();
yield return new WaitUntil(() => getTask.IsCompleted || getTask.IsFaulted);
if (getTask.IsCompleted) {
Debug.Log(getTask.Result.Value.ToString());
}--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/52ae1835-8738-4bdc-be26-3412569643c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
yield return new WaitUntil(() => getTask.IsCompleted || getTask.IsFaulted);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Firebase;
using Firebase.Database;
using Firebase.Unity.Editor;
public class DBManager: MonoBehaviour {
public Text MA1Sensor1;
public Text MA1Sensor2;
void Start() {
// Set up the Editor before calling into the realtime database.
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://unityar-6eb13.firebaseio.com/");
// Get the root reference location of the database.
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
reference.ValueChanged += HandleValueChanged;
}
void HandleValueChanged(object sender, ValueChangedEventArgs args) {
if (args.DatabaseError != null) {
Debug.LogError(args.DatabaseError.Message);
return;
}
// DO SOMETHING WITH THE DATA IN ARGS.SNAPSHOT
var getTask = FirebaseDatabase.DefaultInstance.GetReference ("MA1").Child ("Zaehler").GetValueAsync ();
StartCoroutine (ReadyData ());
if (getTask.IsCompleted) {
Debug.Log(getTask.Result.Value.ToString());
} else
Debug.Log ("If Error");
}
IEnumerator ReadyData() {
var getTask = FirebaseDatabase.DefaultInstance.GetReference ("MA1").Child ("Zaehler").GetValueAsync ();
yield return new WaitUntil (() => getTask.IsCompleted);
}
// Update is called once per frame
void Update ()
{
}
}