Using the CDN to deliver a json file for new levels to a game as and when they are available and a method never gets called. (Any ideas why?)
This is where I am calling the Login method from a call which makes the game world.
void Awake () { PlayFabHelpers.Login }
Below is the class which holds the login method and that seems to work but I have a break point within the DownLoadFile method but it never hits it for some reason. Been looking at this for days and can't solve it.
So any ideas why DownLoadFile from below never gets called ?
using PlayFab; using PlayFab.ClientModels; using System; using System.Collections; using System.IO; using UnityEngine; using UnityEngine.Networking; public static class PlayFabHelpers { public static void Login() { if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId)) { PlayFabSettings.staticSettings.TitleId = "blablabla"; } var request = new LoginWithCustomIDRequest { CustomId = "TestGuy", CreateAccount = true }; PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure); } private static void OnLoginSuccess(LoginResult result) { GetDownloadUrl("Levels.json", OnSuccess); } private static void OnLoginFailure(PlayFabError error) { Debug.LogWarning("Something went wrong with your first API call. :("); Debug.LogError("Here's some debug information:"); Debug.LogError(error.GenerateErrorReport()); } private static void OnSuccess(string obj) { DownloadFile(obj); } public static void AuthenticateWithPlayFab() { Debug.Log("Logging into PlayFab..."); LoginWithCustomIDRequest request = new LoginWithCustomIDRequest() { TitleId = PlayFabSettings.staticSettings.TitleId, CustomId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true }; PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure, null); } public static void DownloadFileFromCDN(string key) { GetDownloadUrl(key, presignedUrl => { Console.WriteLine(""); }); } static void GetDownloadUrl(string key, Action<string> onComplete) { PlayFabClientAPI.GetContentDownloadUrl(new GetContentDownloadUrlRequest() { Key = key, ThruCDN = true }, result => onComplete(result.URL), error => Debug.LogError(error.GenerateErrorReport())); } private static IEnumerator DownloadFile(string thePath) { var uwr = new UnityWebRequest(thePath, UnityWebRequest.kHttpVerbGET); string path = Path.Combine(Application.persistentDataPath, "Levels.json"); uwr.downloadHandler = new DownloadHandlerFile(path); yield return uwr.SendWebRequest(); if (uwr.isNetworkError || uwr.isHttpError) Debug.LogError(uwr.error); else Debug.Log("File successfully downloaded and saved to " + path); } }