【发布时间】:2022-03-13 04:29:15
【问题描述】:
说明
我正在将 .txt 文件加载到列表中,并将其中一个元素设置为我的 Firebase 数据库 defaultInstance RootReference 中的子元素。它需要类型字符串,这就是我要传递的内容。
问题
当我传递从 Resources.Load 或 StreamReader 命令收集的字符串时,不会向数据库添加任何内容。任何其他字符串都按预期工作。
我可以在脚本中对不相关的对象使用 Resources.Load,而不会破坏 Firebase 功能。仅当我尝试使用 Resources.Load 将传递给数据库的特定字符串时才会发生这种情况。
string _roomCode = "RoomNotSelected";
// When using this block, Firebase won't create/write _roomCode in the database.
// Otherwise _roomCode ("RoomNotSelected") is succeffully added as a child in the database at rootReference.
TextAsset txtRooms = (TextAsset)Resources.Load("Room Names Files"); // I also tried Streamreader. It didn't work either.
List<string> roomList = new List<string>(txtRooms.text.Split("\n"[0])); // The text file is one room name per line. Split each line into a list.
_roomCode = roomList[0]; // Use the first element for testing.
Debug.Log(_roomCode); //Prints "TestRoom"
FirebaseDatabase.DefaultInstance.RootReference.Child(_roomCode).Child("Match").SetRawJsonValueAsync(jsonMatch);
问题
Unity 或 Firebase 中有什么东西可以区别对待字符串吗? - 只是因为它是从资源中收集的。
【问题讨论】:
标签: string list firebase unity3d firebase-realtime-database