Hey guys, I spent a few hours trying different solutions and trying other peoples solutions with no avail.
Could anyone help me get this to work? I'm trying to get
UpdateUserData
to add/update to a user but I get this error:
Assets/PlayFabManager.cs(73,36): error CS0246: The type or namespace name `Dictionary' could not be found. Are you missing a using directive or an assembly reference?
My code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using PlayFab;
using PlayFab.ClientModels;
public class PlayFabManager : MonoBehaviour {
public string PlayFabId;
void Login(string titleId)
{
LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
{
TitleId = titleId,
CreateAccount = true,
CustomId = SystemInfo.deviceUniqueIdentifier
};
PlayFabClientAPI.LoginWithCustomID(request, (result) => {
PlayFabId = result.PlayFabId;
Debug.Log("Got PlayFabID: " + PlayFabId);
if(result.NewlyCreated)
{
Debug.Log("(new account)");
}
else
{
Debug.Log("(existing account)");
SetUserData();
GetUserData();
}
},
(error) => {
Debug.Log("Error logging in player with custom ID:");
Debug.Log(error.ErrorMessage);
});
}
void GetUserData()
{
GetUserDataRequest request = new GetUserDataRequest()
{
PlayFabId = PlayFabId,
Keys = null
};
PlayFabClientAPI.GetUserData(request,(result) => {
Debug.Log("Got user data:");
if ((result.Data == null) || (result.Data.Count == 0))
{
Debug.Log("No user data available");
}
else
{
Debug.Log (result.Data["age"].Value);
foreach (var item in result.Data)
{
Debug.Log(" " + item.Key + " == " + item.Value.Value);
}
}
}, (error) => {
Debug.Log("Got error retrieving user data:");
Debug.Log(error.ErrorMessage);
});
}
void SetUserData()
{
UpdateUserDataRequest request = new UpdateUserDataRequest()
{
Data = new Dictionary(){
{"Ancestor", "Arthur"},
{"Successor", "Fred"}
}
};
PlayFabClientAPI.UpdateUserData(request, (result) =>
{
Debug.Log("Successfully updated user data");
}, (error) =>
{
Debug.Log("Got error setting user data Ancestor to Arthur");
Debug.Log(error.ErrorDetails);
});
}
void Awake(){
PlayFabSettings.TitleId = "HIDDEN"; //your title id goes here.
}
// Use this for initialization
void Start () {
Login ("HIDDEN");
}
// Update is called once per frame
void Update () {
}
}
Thank you!