【发布时间】:2019-07-21 19:08:44
【问题描述】:
我正在尝试将 Int32[] 数组和 bool[] 数组存储到 Firebase,但它不适合我。我已经搜索了很多地方,但找不到解决方案。谁能告诉我,如何将数组从 Unity 存储到 Firebase 实时数据库。
我正在使用System.Reflection 来获取UserPrefs 类的所有公共静态字段。
这是代码,我正在尝试做这项工作......
System.Type type = typeof(UserPrefs);
FieldInfo[] fields = type.GetFields();
foreach (var field in fields) {
if (user != null)
dbReference.Child("users").Child(user.UserId).Child(field.Name).SetValueAsync(field.GetValue(null));
else
Debug.LogError("There is no user LoggedIn to write...");
}
上面的代码保存了数组以外的所有值。数组上给出的错误如下:
InvalidCastException:无法从源类型转换到目标 类型。 Firebase.Database.Internal.Utilities.Validation.ValidateWritableObject (System.Object 对象)
任何帮助将不胜感激...
【问题讨论】:
标签: arrays firebase unity3d firebase-realtime-database