public IEnumerator getAllVendors(int limit, int page) { string uri = baseUrl + "/api/products/PublishersHousesListSampleData"; if (limit > 0) { uri += "&limit=" + limit.ToString() + "&page=" + page.ToString(); } AllVendorsResult res = new AllVendorsResult(); UnityWebRequest www = UnityWebRequest.Get(uri); www.SetRequestHeader("Authorization", authInfo.token_type + " " + authInfo.access_token); www.SetRequestHeader("customerId", "1"); www.SetRequestHeader("Content-Type", "application/json"); www.SetRequestHeader("LanguageId", languageId.ToString()); transmitting = true; yield return(www.SendWebRequest()); res = JsonUtility.FromJson <AllVendorsResult>(www.downloadHandler.text); if (res != null) { Cache.Instance.cacheAllVendors(res); vendorsRetrievedEvent.Invoke();//load peliminary data vendorsRetrievedEvent.RemoveAllListeners(); } transmitting = false; }
public void cacheAllVendors(AllVendorsResult vendorsResult) { cachedData.allVendors = vendorsResult.vendorList; foreach (Vendor v in cachedData.allVendors) { //print(v.id+" "+v.name); if (v.defualtPicture != "" && v.defualtPicture != null) { string tmpStr; tmpStr = Convert.ToBase64String(Decompress(Convert.FromBase64String(v.defualtPicture))); v.pic = new Texture2D(1, 1); v.pic.LoadImage(Convert.FromBase64String(tmpStr)); v.pic.Apply(); } } }