Hi, I would like to wait for my playfab result, store it in a variable then run some code. Heres my code.
ClassA Code
public List<myEntityFile> myEntityFileList = new List<myEntityFile>(); public void LoadAllFiles() { if (GlobalFileLock != 0) throw new Exception("This example overly restricts file operations for safety. Careful consideration must be made when doing multiple file operations in parallel to avoid conflict."); GlobalFileLock += 1; // Start GetFiles var request = new PlayFab.DataModels.GetFilesRequest { Entity = new PlayFab.DataModels.EntityKey { Id = entityId, Type = entityType } }; PlayFabDataAPI.GetFiles(request, OnGetFileMeta, OnSharedFailure); } void OnGetFileMeta(PlayFab.DataModels.GetFilesResponse result) { Debug.Log("Loading " + result.Metadata.Count + " files"); _entityFileJson.Clear(); foreach (var eachFilePair in result.Metadata) { _entityFileJson.Add(eachFilePair.Key, null); GetActualFile(eachFilePair.Value); } GlobalFileLock -= 1; // Finish GetFiles } void GetActualFile(PlayFab.DataModels.GetFileMetadata fileData) { GlobalFileLock += 1; // Start Each SimpleGetCall PlayFabHttp.SimpleGetCall(fileData.DownloadUrl, result => { _entityFileJson[fileData.FileName] = Encoding.UTF8.GetString(result); GlobalFileLock -= 1; Debug.Log("My file is " + fileData.FileName); Debug.Log("My file download url is " + fileData.DownloadUrl); myEntityFileList.Add(new MyEntityFile(fileData.FileName, fileData.DownloadUrl)); }, // Finish Each SimpleGetCall error => { Debug.Log(error); } ); }
As you can see, this is how we can retrieve entity files in Playfab, in my `GetActualFile` function, I have a line that adds the retrieved data to myEntityFileList.
I want to eventually use the myEntityFileList to run some operation.
ClassB Code
ClassA.classA.LoadAllFiles(); // I want to load the file (classA is a singleton here) // There should be a pause here, wait until ALL files are loaded List<myEntityFile> myFileList = ClassA.classA.myEntityFileList; // then my variables will now store all the info, and I can do something with the data foreach(myEntityFile myFile in myFileList){ // do something }
Please provide some advice on how I can achieve this! Thank you!