【发布时间】:2017-10-08 02:10:27
【问题描述】:
在听说 Firebase 之后,我决定在我的 Unity 小游戏上试用它是个好主意。
我阅读了文档,按照“入门”配置教程,更改了身份验证规则,以便每个人都可以插入数据。
void Start()
{
// Set up the Editor before calling into the realtime database.
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://magicast-bd2fc.firebaseio.com/");
Firebase.Auth.FirebaseAuth.DefaultInstance.StateChanged += DefaultInstance_StateChanged;
// Get the root reference location of the database.
DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
var u = new User();
u.email = "sdjkdsdksadjsad";
u.fb_id = "sakdsajdhasd";
u.username = "jadhsjahjsda";
reference.SetValueAsync(u);
}
此代码确实执行了,但是当我转到 Firebase 控制台时,我在“数据库”选项卡上看不到任何数据。我无法弄清楚我做错了什么,并且代码根本没有错误!我做错了什么?
这是我的用户类。它基本上是一个测试类,没什么大不了的:
public class User
{
public string username;
public string email;
public string fb_id;
public User()
{
}
public User(string username, string email, string fb_id)
{
this.username = username;
this.email = email;
this.fb_id = fb_id;
}
}
【问题讨论】:
标签: c# firebase unity3d firebase-realtime-database