Ejemplo n.º 1
0
    public IEnumerator SearchArticle(string query)
    {
        if (resultsAPI.Length > 0)
        {
            resultsAPI = new ArticleSerializable[0];
        }

        url = GameObject.Find("GlobalManager").GetComponent <GlobalManager> ().url;
        string endPoint = "/forest/v1/articles/?search=";

        UnityWebRequest webRequest = UnityWebRequest.Get(url + endPoint + query);

        yield return(webRequest.Send());

        if (!webRequest.isError)
        {
            ArticleListSerializable articleList = JsonUtility.FromJson <ArticleListSerializable> (
                JSONHelpers.WrapToClass("articles", webRequest.downloadHandler.text)
                );

            resultsAPI = articleList.articles;
        }
        else
        {
            Debug.Log(webRequest.error);
        }
    }
Ejemplo n.º 2
0
    public IEnumerator GetThematics(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.Send());

        if (!webRequest.isError)
        {
            ThematicListSerializable thematicList = JsonUtility.FromJson <ThematicListSerializable> (
                JSONHelpers.WrapToClass("thematics", webRequest.downloadHandler.text)
                );

            thematics = thematicList.thematics;
        }
        else
        {
            Debug.Log(webRequest.error);
        }
    }
Ejemplo n.º 3
0
    public IEnumerator GetCategories(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.Send());

        if (!webRequest.isError)
        {
            CategoryListSerializable categoryList = JsonUtility.FromJson <CategoryListSerializable> (
                JSONHelpers.WrapToClass("categories", webRequest.downloadHandler.text)
                );

            categories = categoryList.categories;
        }
        else
        {
            Debug.Log(webRequest.error);
        }
    }