Ejemplo n.º 1
0
    public void GetCategories(int categoryId, OnRecievedCategoriesCallback onRecievedCategories)
    {
        var _url = GameHiddenOptions.Instance.ServerURL + _urlGetCategories + "?categoryId=" + categoryId;

        OnRecievedCategories = onRecievedCategories;
        StartCoroutine(WaitForRequest(_url));
    }
Ejemplo n.º 2
0
    private IEnumerator WaitForRequest(string _url)
    {
        UnityWebRequest www = UnityWebRequest.Get(_url);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.LogError(www.error);
        }
        else
        {
            if (OnRecievedCategories != null)
            {
                Debug.Log(www.downloadHandler.text);

                Category[] categories = JsonHelper.FromJson <Category>(www.downloadHandler.text);
                OnRecievedCategories(categories.ToList());
                OnRecievedCategories = null;
            }
        }
    }