Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法从unity3d中的firebase实时数据库检索数据_C#_Firebase_Unity3d_Firebase Realtime Database - Fatal编程技术网

C# 无法从unity3d中的firebase实时数据库检索数据

C# 无法从unity3d中的firebase实时数据库检索数据,c#,firebase,unity3d,firebase-realtime-database,C#,Firebase,Unity3d,Firebase Realtime Database,我是unity firebase开发者的新手。基本上,我制作了一个函数GetPlayerPrize,从firebase获取特定的(登录用户)奖品详细信息。但在从firebase实时数据库检索数据时,我无法得到任何响应 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Firebase; using Firebase.Auth; usi

我是unity firebase开发者的新手。基本上,我制作了一个函数
GetPlayerPrize
,从firebase获取特定的(登录用户)奖品详细信息。但在从firebase实时数据库检索数据时,我无法得到任何响应

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Firebase;
using Firebase.Auth;
using Firebase.Database;
using Firebase.Unity.Editor;
public class prizeCanvasScript : MonoBehaviour
{
public Text silver;
public Text gold;
public Button silverButton;
public Button GoldButton;
public Firebase.Auth.FirebaseAuth auth;
public Firebase.Auth.FirebaseUser user;

public void Start() {
    InitializeFirebase();
}

public void InitializeFirebase()
{
    FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://robberbird.firebaseio.com/");
    auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
    user = auth.CurrentUser;
    GetPlayerPrize();
}


void GetPlayerPrize() 
{
    Debug.Log("Getting player data" + user.UserId);

     FirebaseDatabase.DefaultInstance
    .GetReference("users")
    .Child(user.UserId)
    .GetValueAsync()
    .ContinueWith((task) =>{
        if (task.IsFaulted)
        {
            Debug.LogError("Error retriving user data: " + user.UserId);
            // Handle the error...
        }
        else if (task.IsCompleted)
        {
            DataSnapshot snapshot = task.Result;
            Debug.Log("snapshot" );
            Debug.Log(snapshot);                             
            // silver.text = snapshot.silverChest.ToString();
            // gold.text = snapshot.GoldChest.ToString();
        }
    });

}
}

是否使用任务引用默认实例

static Task DI = new System.Threading.Tasks.Task(LoginAnon);

public static void LoginAnon()
{
    DI = FirebaseAuth.DefaultInstance.SignInAnonymouslyAsync().ContinueWith(result =>
    {
        FirebaseDatabase.DefaultInstance.GetReference("Lobbies/").ChildAdded += HandleLobbyAdded;
        FirebaseDatabase.DefaultInstance.GetReference("Lobbies/").ChildRemoved += HandleLobbyRemoved;
    });
}


你是说这两个都不是Debug.LogError(“错误检索用户数据:“+user.UserId”)
调试日志(“快照”) public static void HandleLobbyRemoved(object sender, ChildChangedEventArgs e)
{
    DataSnapshot snap = e.Snapshot;
    if (e.DatabaseError != null)
    {
        Debug.LogError(e.DatabaseError.Message);
        return;
    }
    //User who created the lobby
    string uID = snap.Key.ToString();
}