Exemplo n.º 1
0
    public IEnumerator getCurrentFairs()
    {
        //temporary until badawy gives us another endpoint
        string uri = baseUrl + "/api/fairs/FairsList";

        FairResult res = new FairResult();

        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", "1");

        transmitting = true;

        yield return(www.SendWebRequest());

        res = JsonUtility.FromJson <FairResult>(www.downloadHandler.text);
        if (res != null)
        {
            Cache.Instance.cacheAllFairs(res);
            fairsRetrievedEvent.Invoke();
        }

        transmitting = false;
    }
Exemplo n.º 2
0
    public void cacheAllFairs(FairResult fairResult)
    {
        cachedData.allFairs = fairResult.fairsList;

        foreach (FairData f in cachedData.allFairs)
        {
            if (f.logoPictureBinary != "" && f.logoPictureBinary != null)
            {
                string tmpStr;
                tmpStr = Convert.ToBase64String(Decompress(Convert.FromBase64String(f.logoPictureBinary)));
                f.pic  = new Texture2D(1, 1);
                f.pic.LoadImage(Convert.FromBase64String(tmpStr));
                f.pic.Apply();
            }
        }
    }