I'm having problem "delay" when i tried to Get data from the character.
I have 2 function in different class
public List<string> DataResult = new List<string>(); public List<string> GetDataCharacter(List<string>Keys) { PlayFabClientAPI.GetCharacterData( new GetCharacterDataRequest() { CharacterId = charID, Keys = Keys }, (GetCharacterDataResult result) => { for (int i = 0; i < Keys.Count; i++) { DataResult.Add(result.Data[Keys[i]].Value); } }, (PlayFabError error) => { Debug.Log(error); } ); return DataResult; }
public void GetData() { List<string> TestKeysData = new List<string>(); TestKeysData.Add("Hair"); TestKeysData.Add("Skin"); TestKeysData.Add("Eyes"); _loginController.GetDataCharacter(TestKeysData); List<string> ResultData = _loginController.GetDataCharacter(TestKeysData); Debug.Log("count "+ _loginController.GetData(TestKeysData).Count); //Debug "count 0" Debug.Log("count " + ResultData.Count); //Debug "count 0" StartCoroutine(GetDataCoroutine()); }
IEnumerator GetDataCoroutine() { List<string> TestKeysData = new List<string>(); TestKeysData.Add("Hair"); TestKeysData.Add("Skin"); TestKeysData.Add("Eyes"); _loginController.GetDataCharacter(TestKeysData); yield return new WaitForSeconds(1); Debug.Log("Count " + _loginController.DataResult.Count); //Debug "count 3" }
It's seems when try get data there is some "delay". Is there any solution so i can use without coroutine for WaitForSeconds?
,