首页 > 解决方案 > Unity Firestore - 字符串的 .value 始终为空 *Bug

问题描述

嗨, 我在我的应用程序的任何地方都使用 Firestore,它运行良好,但是在这个地方它非常奇怪,请在下面自己查看。

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:

有几件事不在这里!

我正在尝试读取该值,但它是空的???

所以我的问题是,我在这里做错了什么?我怎样才能在手机上获得价值?

今天做了一些测试:

所以我将路径从“社交/国家/国际/大厅 1/”更改为“社交/大厅 1/”

第一次工作,但不是第二次。我仍然有同样的错误???

为什么当我更改路径时它第一次运行良好?

标签: c#firebaseunity3dgoogle-cloud-firestore

解决方案


推荐阅读