public Form1()
{
InitializeComponent();
}
public static Form1 ThisInstance = null;
public Form1()
{
InitializeComponent();
ThisInstance = this;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Database;
using Firebase.Unity.Editor;
using UnityEngine.UI;
using System.Threading.Tasks;
public class DBManager : MonoBehaviour
{
public Text qText, btAnswer1, btAnswer2, btAnswer3, btAnswer4;
private int QuestionNumber;
void Start() {
ReadQuestions();
}
void ReadQuestions() {
FirebaseDatabase.DefaultInstance.GetReference("questions/" + strCurrQuest).GetValueAsync().ContinueWith(task => {
if (task.IsFaulted) {
Debug.Log("Не могу прочитать базу данных");
}
else if (task.IsCompleted) {
DataSnapshot snapshot = task.Result;
Form1.Invoke((MethodInvoker)delegate
{
Form1.ThisInstance.qText.text = snapshot.Child("0").Value.ToString();
Form1.ThisInstance.btAnswer1.text = snapshot.Child("1").Value.ToString();
Form1.ThisInstance.btAnswer2.text = snapshot.Child("2").Value.ToString();
Form1.ThisInstance.btAnswer3.text = snapshot.Child("3").Value.ToString();
Form1.ThisInstance.btAnswer4.text = snapshot.Child("4").Value.ToString();
Debug.Log(Form1.ThisInstance.qText.text);
Debug.Log(Form1.ThisInstance.btAnswer1.text);
Debug.Log(Form1.ThisInstance.btAnswer2.text);
Debug.Log(Form1.ThisInstance.btAnswer3.text);
Debug.Log(Form1.ThisInstance.btAnswer4.text);
});
}
});
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Database;
using Firebase.Unity.Editor;
using UnityEngine.UI;
using System.Threading.Tasks;
public class DBManager : MonoBehaviour
{
private static DBManager ThisInstance = null;
public Text qText, btAnswer1, btAnswer2, btAnswer3, btAnswer4;
private int QuestionNumber;
void Awake() {
ThisInstance = this;
}
void Start() {
ReadQuestions();
}
void ReadQuestions() {
FirebaseDatabase.DefaultInstance.GetReference("questions/" + strCurrQuest).GetValueAsync().ContinueWith(task => {
if (task.IsFaulted) {
Debug.Log("Не могу прочитать базу данных");
}
else if (task.IsCompleted) {
DataSnapshot snapshot = task.Result;
tmpformacc.Invoke((MethodInvoker)delegate
{
ThisInstance.qText.text = snapshot.Child("0").Value.ToString();
ThisInstance.btAnswer1.text = snapshot.Child("1").Value.ToString();
ThisInstance.btAnswer2.text = snapshot.Child("2").Value.ToString();
ThisInstance.btAnswer3.text = snapshot.Child("3").Value.ToString();
ThisInstance.btAnswer4.text = snapshot.Child("4").Value.ToString();
Debug.Log(ThisInstance.qText.text);
Debug.Log(ThisInstance.btAnswer1.text);
Debug.Log(ThisInstance.btAnswer2.text);
Debug.Log(ThisInstance.btAnswer3.text);
Debug.Log(ThisInstance.btAnswer4.text);
});
}
});
}
}