I am getting an error on the code in this tutorial
https://firebase.google.com/docs/database/unity/save-data
Below is the code section I am having trouble with. I am getting the error on two lines, 26 and 27.
result["uid"] = uid: this gives me the "Cannot implicitly convert type `string' to `UnityEngine.Object'
result["score"] = score: this gives me the "Cannot implicitly convert type `int' to `UnityEngine.Object'
public class FirebaseController : MonoBehaviour {
[System.Serializable]
public class LeaderBoardEntry : System.Object {
public string uid;
public int score = 0;
public LeaderBoardEntry() {
}
public LeaderBoardEntry(string uid, int score) {
this.uid = uid;
this.score = score;
}
public Dictionary<string, Object> ToDictionary() {
Dictionary<string, Object> result = new Dictionary<string, Object>();
result["uid"] = uid; //Line:26
result["score"] = score; //Line:27
return result;
}
}
DatabaseReference mDatabaseRef;
// Use this for initialization
void Start () {
// Set up the Editor before calling into the realtime database.
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://downhillslalom-8c3e6.firebaseio.com/");
// Get the root reference location of the database.
mDatabaseRef = FirebaseDatabase.DefaultInstance.RootReference;
}
public void setHighscoreData(int Hscore) {
string uid = PlayerPrefs.GetString("userName");
int score = Hscore;
string key = mDatabaseRef.Child("Scores").Push().Key;
LeaderBoardEntry entry = new LeaderBoardEntry(uid, score);
Dictionary<string, Object> entryValues = entry.ToDictionary();
Dictionary<string, Object> childUpdates = new Dictionary<string, Object>();
childUpdates["/Scores/" + key] = entryValues;
mDatabaseRef.UpdateChildrenAsync(childUpdates);
}
}
Please help.
Thanks