- Home /
Text in the scene is not being updated!
Hi, I am new with unity and I am still learning. Basically I am trying to make a quiz game with the questions in the firebase database. With this script I am bringing the data as a snapshot, changing the value to a string and then setting it to a string text. and then setting this string to text in the scene(I think I am good till here) But when I run the game, in inspector question text is set to data from firebase but in the game scene, nothing changes. As my search, this was a bug and it is solved but I am having it still with 2019.2.17f1. Can someone help to fix or workaround this problem?
Here is script;
using Firebase;
using Firebase.Database;
using Firebase.Unity.Editor;
using UnityEngine;
using UnityEngine.UI;
public class DatabaseFire : MonoBehaviour
{
void Start()
{
Text questionText = GameObject.Find("Canvas/GamePanel/QuestionPanel/Question").GetComponent<Text>();
// Set this before calling into the realtime database.
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("blabla.firebaseio.com/");
// Get the root reference location of the database.
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
FirebaseDatabase.DefaultInstance
.GetReference("TR")
.Child("TR")
.Child("question")
.GetValueAsync()
.ContinueWith(task =>
{
if (task.IsFaulted)
{
// Handle the error...
}
else if (task.IsCompleted)
{
DataSnapshot snapshot = task.Result;
string dtext = snapshot.Value.ToString();
questionText.text = dtext;
Debug.Log(dtext);
}
});
}
}
thank you.
Have you tried calling SetLayoutDirty on the Text?
Are you sure the Text object you found using Find is the right one?
Your answer
![](https://koobas.hobune.stream/wayback/20220612221616im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can we refer to two rigidbodies2d in a single script? 0 Answers
i cant drag text to the inspector 2 Answers
How to optimize a custom editor ? 3 Answers
Multiple Cars not working 1 Answer