c# - Unity Firestore - 字符串的 .value 始终为空 *Bug
问题描述
嗨, 我在我的应用程序的任何地方都使用 Firestore,它运行良好,但是在这个地方它非常奇怪,请在下面自己查看。
SocialDocumentListener = SocialDocument.Listen(snapshot => {
Dictionary<string, object> TchatDictionary = snapshot.ToDictionary();
foreach (KeyValuePair<string, object> x in TchatDictionary)
{
Debug.Log($"<color=purple>Social/Country/{UserSocial.GetLobbyType()}/{UserSocial.GetLobbyName()} -> Key:{x.Key} / Value:{x.Value}</color>\n");
if (x.Key.Contains("M_"))
{
if (x.Value.ToString().Length >= 22)
{
string stamp = x.Value.ToString();
string sPlatform = stamp.Substring(0, 3);
string sCountry = stamp.Substring(3, 2);
string sTime = stamp.Substring(5, 10);
string sColor = stamp.Substring(15, 6);
string sMessage = stamp.Substring(21, (stamp.Length - 21));
string sName = x.Key.Substring(10, (x.Key.Length - 10));
long iTime = long.Parse(sTime);
float fColor = ((float.Parse(sColor)) / 1000);
NewDataMessage.Add(new Struct_Message(sPlatform, sCountry, sName, sMessage, iTime, fColor));
}
}
}
}
这是编辑器中的结果,奇怪的是它做了两次但它有效!:D。
Social/Country/International/Lobby 1 -> Key:ID / Value:1
Social/Country/International/Lobby 1 -> Key:Lobby / Value:System.Collections.Blabla
Social/Country/International/Lobby 1 -> Key:M_34KCY5CSSebTHEking / Value:ANDCA1206214822211000Merci
Social/Country/International/Lobby 1 -> Key:M_EWS7VVGPSebTHEking / Value:ANDCA1206202756211000lol
Social/Country/International/Lobby 1 -> Key:M_4W8Y5R3NPlayer82287 / Value:ANDCA1206213816029000sup
Social/Country/International/Lobby 1 -> Key:M_YU24X2P4SebTHEking / Value:ANDCA1206214206211000hey
Social/Country/International/Lobby 1 -> Key:M_GUPICC36SebTHEking / Value:ANDCA1206214220211000bye
Social/Country/International/Lobby 1 -> Key:M_VP8Y7N5QSebTHEking / Value:ANDCA1206214215211000hello
Social/Country/International/Lobby 1 -> Key:ID / Value:1
Social/Country/International/Lobby 1 -> Key:Lobby / Value:System.Collections.Blabla
Social/Country/International/Lobby 1 -> Key:M_34KCY5CSSebTHEking / Value:ANDCA1206214822211000Merci
Social/Country/International/Lobby 1 -> Key:M_EWS7VVGPSebTHEking / Value:ANDCA1206202756211000lol
Social/Country/International/Lobby 1 -> Key:M_4W8Y5R3NPlayer82287 / Value:ANDCA1206213816029000sup
Social/Country/International/Lobby 1 -> Key:M_YU24X2P4SebTHEking / Value:ANDCA1206214206211000hey
Social/Country/International/Lobby 1 -> Key:M_GUPICC36SebTHEking / Value:ANDCA1206214220211000bye
Social/Country/International/Lobby 1 -> Key:M_VP8Y7N5QSebTHEking / Value:ANDCA1206214215211000hello
现在这是我的手机 Android Samsumg S9+ 上的结果
Social/Country/International/Lobby 1 -> Key:M_34KCY5CSSebTHEking / Value:
Social/Country/International/Lobby 1 -> Key:M_EWS7VVGPSebTHEking / Value:
Social/Country/International/Lobby 1 -> Key:Lobby / Value:System.Collections.Blabla
Social/Country/International/Lobby 1 -> Key:M_YU24X2P4SebTHEking / Value:
Social/Country/International/Lobby 1 -> Key:M_VP8Y7N5QSebTHEking / Value:
Social/Country/International/Lobby 1 -> Key:M_4W8Y5R3NPlayer82287 / Value:
Social/Country/International/Lobby 1 -> Key:ID / Value:1
Social/Country/International/Lobby 1 -> Key:M_GUPICC36SebTHEking / Value:
有几件事不在这里!
- debug.log 的顺序
- 值为空(当它是一个字符串时)
- 值还可以(当它是一个数字时?!)
我正在尝试读取该值,但它是空的???
所以我的问题是,我在这里做错了什么?我怎样才能在手机上获得价值?
今天做了一些测试:
所以我将路径从“社交/国家/国际/大厅 1/”更改为“社交/大厅 1/”
第一次工作,但不是第二次。我仍然有同样的错误???
为什么当我更改路径时它第一次运行良好?
解决方案
推荐阅读
- here-api - HERE Search API 总是返回 0 张图片
- javascript - 带预览的 HTML5 视频
- vue.js - How to unit test standalone Vue composition
- matlab - 如何在 MATLAB 上生成 Nakagami–m 衰落通道?
- javascript - 如何获取 httpOnly(安全)cookie TestCafe?
- permutation - 生成所有无序组合
- go - JWT 不验证收到的令牌
- regex - IF - ELSE 语句 Google Sheets 各种值
- java - 在百里香中动态填充列表
- swift - 在 SceneKit 中捕获没有背景的节点的图像