Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unity的Firebase是否包含childByAutoId?_Firebase_Unity3d_Firebase Realtime Database - Fatal编程技术网

Unity的Firebase是否包含childByAutoId?

Unity的Firebase是否包含childByAutoId?,firebase,unity3d,firebase-realtime-database,Firebase,Unity3d,Firebase Realtime Database,我是一名经验丰富的Firebase用户,最近正在与Unity 2019合作一个游戏项目。UnityFirebase框架是否包含与iOS/Web中可用的childByAutoId等效的 public void UploadHighScore(Highscore highscore) { string json = JsonUtility.ToJson(highscore); reference .Child("Highscores") .ChildByA

我是一名经验丰富的Firebase用户,最近正在与Unity 2019合作一个游戏项目。UnityFirebase框架是否包含与iOS/Web中可用的childByAutoId等效的

public void UploadHighScore(Highscore highscore) {

    string json = JsonUtility.ToJson(highscore);

    reference
      .Child("Highscores")
      .ChildByAutoID // does not exist
      .SetRawJsonValueAsync(json);
}

在C#中是否有另一种获得唯一ID的最佳实践方法?

在Unity上调用该方法


在Firebase支持的大多数平台上,它实际上被称为
push()
,而iOS将其称为
childByAutoId()
,Frank正确回答了我的问题,并提供了文档参考。 下面是一个代码示例,以防其他人遇到此问题

public void UploadHighScore(Highscore highscore) {

    DatabaseReference location = reference
     .Child("Highscores")
     .Push();

    highscore.uuid = location.Key; // storing the uuid for later usage like deletion etc
    string json = JsonUtility.ToJson(highscore);
    location.SetRawJsonValueAsync(json);
    Debug.Log($"auto generated ID: {location.Key}"); // new child uuid
}

谢谢你,弗兰克。总是一个完美而快速的答案。我感谢您提供的文档参考。