protected IEnumerator titleDataQuerry(GetTitleDataRequest request) { wait = true; PlayFabClientAPI.GetTitleData(request, (result) => { Debug.Log("Got title data:"); if ((result.Data == null) || (result.Data.Count == 0)) { Debug.Log("No title data available"); } else { succesfullTitleDataQuerry(result); } querrySuccesfull = true; wait = false; }, (error) => { failedTitleDataQuerry(error); this.error = error; querrySuccesfull = false; wait = false; }); while (wait) { yield return null; } }
// Use this for initialization void Start () { GetTitleDataRequest request = new GetTitleDataRequest (); List<string> keys = new List<string> (); keys.Add ("connectionlost"); keys.Add ("nocoins"); keys.Add ("icon_currency"); keys.Add ("icon_health"); keys.Add ("icon_kill"); request.Keys = keys; if (PlayFabData.AuthKey != null) PlayFabClientAPI.GetTitleData (request, OnTitleData, OnPlayFabError); }
private void LoadTitleData(string authKey = null) { GetTitleDataRequest request = new GetTitleDataRequest (); List<string> keys = new List<string> (); keys.Add ("connectionlost"); keys.Add ("nocoins"); keys.Add ("icon_currency"); keys.Add ("icon_health"); keys.Add ("icon_kill"); request.Keys = keys; PlayFabClientAPI.GetTitleData (request, OnTitleData, OnPlayFabError); }
/// <summary> /// Retrieves the key-value store of custom title settings /// </summary> public static void GetTitleData(GetTitleDataRequest request, GetTitleDataCallback resultCallback, ErrorCallback errorCallback) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings); Action<string,string> callback = delegate(string responseStr, string errorStr) { GetTitleDataResult result = null; PlayFabError error = null; ResultContainer<GetTitleDataResult>.HandleResults(responseStr, errorStr, out result, out error); if(error != null && errorCallback != null) { errorCallback(error); } if(result != null) { if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/GetTitleData", serializedJSON, "X-Authorization", AuthKey, callback); }
/// <summary> /// Retrieves the key-value store of custom title settings /// </summary> public static void GetTitleData(GetTitleDataRequest request, ProcessApiCallback<GetTitleDataResult> resultCallback, ErrorCallback errorCallback, object customData = null) { if (_authKey == null) throw new Exception("Must be logged in to call this method"); string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy); Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer) { ResultContainer<GetTitleDataResult>.HandleResults(requestContainer, resultCallback, errorCallback, null); }; PlayFabHTTP.Post("/Client/GetTitleData", serializedJson, "X-Authorization", _authKey, callback, request, customData); }
/// <summary> /// Retrieves the key-value store of custom title settings /// </summary> public static async Task<PlayFabResult<GetTitleDataResult>> GetTitleDataAsync(GetTitleDataRequest request) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetTitleData", request, "X-Authorization", AuthKey); if(httpResult is PlayFabError) { PlayFabError error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) PlayFabSettings.GlobalErrorHandler(error); return new PlayFabResult<GetTitleDataResult> { Error = error, }; } string resultRawJson = (string)httpResult; var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetTitleDataResult>>(new JsonTextReader(new StringReader(resultRawJson))); GetTitleDataResult result = resultData.data; return new PlayFabResult<GetTitleDataResult> { Result = result }; }
public override IEnumerator makeQuerry() { GetTitleDataRequest request = new GetTitleDataRequest(); yield return titleDataQuerry(request); }
/// <summary> /// Gets All title data from PlayFab. /// </summary> public void LoadTitleData() { GetTitleDataRequest request = new GetTitleDataRequest(); request.Keys = new List<string>() { "Key_Home", "Key_Play", "Key_Store", "Key_Settings", "Key_Tutorial", "Key_MainMenuBtn", "Key_StoreBtn", "Key_PlayAgainBtn", "Key_Loading", "Key_SelectChar", "Key_Stats", "Key_ChangeTeam", "Key_Vs", "Key_TypeMessage", "Key_LeaveGameBtn", "Key_Player", "Key_Statistics", "Key_Options", "Key_LeaveGameTitle", "Key_LeaveGameText", "Key_Yes", "Key_No", "Key_ModeSelectTitle", "Key_CreateMatch", "Key_JoinMatch", "Key_ComingSoon", "Key_LeaderboardTitle", "Key_Level", "Key_Kills", "Key_Wins", "Key_Inventory", "Key_XP", "Key_BuySecondChar", "Key_BuySecondCharText", "Key_NoThanks", "Key_OhYes", "Key_Tutorial_Pg1Item1", "Key_Tutorial_Pg1Item2", "Key_Tutorial_Pg1Item3", "Key_Tutorial_Pg1Item4", "Key_Tutorial_Pg2Item1", "Key_Tutorial_Pg2Item2", "Key_Tutorial_Pg2Item3", "Key_Tutorial_Pg2Item4" }; PlayFabClientAPI.GetTitleData(request, OnTitleDataLoadSuccess, OnTitleDataLoadError); }
//get data title public void ClientGetTitleData (Action<Dictionary<string,string>> action) { GetTitleDataRequest getRequest = new GetTitleDataRequest (); PlayFabClientAPI.GetTitleData (getRequest, (result) => { Debug.Log ("Got the following titleData:"); Dictionary<string,string> lstValueData = new Dictionary<string, string> (); foreach (var entry in result.Data) { lstValueData.Add (entry.Key, entry.Value); } action (lstValueData); }, (error) => { Debug.Log ("Got error getting titleData:"); Debug.Log (error.ErrorMessage); }); }