【问题标题】:Can't set firebase timestamp with unity无法统一设置 Firebase 时间戳
【发布时间】:2017-05-08 09:00:05
【问题描述】:
//save data
private void writeNewUser(string userId, string name, string email)
{
    User user = new User(name, email);
    string json = JsonUtility.ToJson(user);
    //save user data with json
    mDatabaseRef.Child("users").Child(userId).SetRawJsonValueAsync(json);
    //save time
    mDatabaseRef.Child("time").SetValueAsync(Firebase.Database.ServerValue.Timestamp);

    Debug.Log("firebase DB write done");
    t_debug.text = "firebase DB write done";

}

用户数据保存成功,但时间戳出错。 如何将时间图保存到服务器? 搜了很多帖子,大部分都是java或者android原生的,看不懂。

谢谢。

userdata success

error with timestamp

【问题讨论】:

    标签: firebase unity3d firebase-realtime-database timestamp


    【解决方案1】:

    解决了。问题是统一的 Json 构建器不适用于字典。

    Can't set firebase timestamp with unity

    是提示。

    我刚刚在构建的 Json 字符串的末尾添加了字符串,现在可以很好地节省时间。

    //save data
    private void writeNewUser(string userId, string name, string email)
    {
        User user = new User(name, email);
        string json = JsonUtility.ToJson(user);
        Debug.Log("original");
        Debug.Log(json);
    
        json = json.Substring(0, json.Length-1);
        Debug.Log("cutted");
        Debug.Log(json);
    
        string timestampAdd = @" , ""timestamp"": {"".sv"" : ""timestamp""} } ";
        Debug.Log("adder");
        Debug.Log(timestampAdd);
        json = json + timestampAdd;
        Debug.Log("added");
        Debug.Log(json);
    
        //save user data with json
        mDatabaseRef.Child("users").Child(userId).SetRawJsonValueAsync(json);
    
        Debug.Log("firebase DB write done");
        t_debug.text = "firebase DB write done";
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-03
      • 1970-01-01
      相关资源
      最近更新 更多