c# - 如何从 Firebase unity c# 中的数据快照获取密钥?
问题描述
我正在尝试使用 Unity 和 Firebase SDK 构建游戏。我想获得图像中圆圈的关键。
FirebaseDatabase.DefaultInstance
.GetReference("live_games")
.OrderByChild("gameId").EqualTo(GAME_KEY)
.GetValueAsync().ContinueWith(task => {
if (task.IsFaulted)
{
// Handle the error...
}
else if (task.IsCompleted)
{
DataSnapshot snapshot = task.Result;
Debug.Log("the json " + snapshot.GetRawJsonValue());
Debug.Log("the key is "+ snapshot.Key);
// Do something with snapshot...
}
});
我得到的钥匙是“live_games”而不是“0”
解决方案
谢谢道格史蒂文森它工作
FirebaseDatabase.DefaultInstance
.GetReference("live_games")
.OrderByChild("gameId").EqualTo(GAME_KEY)
.GetValueAsync().ContinueWith(task => {
if (task.IsFaulted)
{
// Handle the error...
}
else if (task.IsCompleted)
{
DataSnapshot snapshot = task.Result;
foreach(var child in snapshot.Children)
{
Debug.Log("The Key"+child.Key);
}
// Do something with snapshot...
}
});
推荐阅读
- laravel - 目标类 [ProductController] 不存在。拉拉维尔 5.8
- javascript - vscode中的减速
- laravel - 如何在heroku中为laravel添加后台任务
- git - 如何在推送到另一个分支时触发 Github Actions 工作流?
- python - 如何从另一个脚本访问一个 python 脚本中的变量
- php - 从 Flutter 向 PHP/MYSQL Server 发布密码的最佳实践?
- python-3.x - 如何在决策树中获取新数据的标签编码器
- html - 引导导航栏颜色不变
- r - 转换和绘制两个数字和频率
- python - Django,如何仅获取数据库中保存的最新数据?