I have a more general question regarding Unity C# and the brand new Firebase SDK. I've looked through all of the new documentation and haven't seen an answer to this yet. If you retrieve data from the database below, it doesn't allow you to execute methods like Instantiate inside this function because it is not happening on the main thread. How would you go about doing this? TLDR I want to know how to execute game functions after or while retrieving stuff from Firebase.
FirebaseDatabase.DefaultInstance
.GetReference("Scenes").OrderByChild("order")
.ValueChanged += (object sender2, ValueChangedEventArgs e2) => {
if (e2.DatabaseError != null) {
Debug.LogError(e2.DatabaseError.Message);
}
scenes = asset.text.Split('\n');
return;
}
if (e2.Snapshot != null && e2.Snapshot.ChildrenCount > 0) {
sceneCollection.Clear();
foreach (var childSnapshot in e2.Snapshot.Children) {
var sceneName = childSnapshot.Child("name").Value.ToString();
sceneCollection.Add( new SceneItem(sceneName, 0));
// I WANTED TO INSTANTIATE SOMTHING HERE
}
}
};