Esempio n. 1
0
    IEnumerator PictureRoutine(string query)
    {
        //delete old images
        pictureFactory.DeleteOldPictures();
        //deactivate text object until objects are done getting placed
        queryText.transform.parent.gameObject.SetActive(false);
        //save camera forward vector so we can move around while objects are getting placed
        Vector3 cameraForward = Camera.main.transform.forward;
        //we can only get 10 results at a time so we have to loop through and save our progress changing the start number after every 10
        int results = 1;

        for (int i = 1; i <= 60; i += 10)
        {
            string url = "https://www.googleapis.com/customsearch/v1?q=" + WWW.EscapeURL(query) +
                         "&cx=" + SEARCH_ENGINE_ID + "&imgSize=large&searchType=image&start=" + i + "&&fields=items%2Flink&filter=0&key=" + API_KEY;
            WWW www = new WWW(url);
            yield return(www);

            ParseResponse(www.text);
            print(www.text);
            pictureFactory.CreateImages(urlList, results, cameraForward);
            results++;
        }
        yield return(new WaitForSeconds(5f));

        queryText.transform.parent.gameObject.SetActive(true);
    }
Esempio n. 2
0
    IEnumerator PictureRoutiine()
    {
        buttonText.transform.parent.gameObject.SetActive(false);
        string query = buttonText.text;

        query = WWW.EscapeURL(query + " memes");
        //Esto es para eliminar las nuevas imagenes para una nueva busqueda
        pictureFactory.DeleteOldPictures();
        Vector3 cameraForward = Camera.main.transform.forward;

        //Buscar solo 10 imagenes segun configuracion en google panel
        int rowNum = 1;

        for (int i = 1; i < 60; i += 10)
        {
            string url = "https://www.googleapis.com/customsearch/v1?q=" + query + "&cx=017319053153040316754%3Aduciwq-c0iq&filter=1&num=10&searchType=image&start=" + i + "&fields=items%2Flink&key=" + API_KEY;

            WWW www = new WWW(url);
            yield return(www);

            //Para crear imagenes esto tomara una lista de string
            pictureFactory.CreateImages(ParseResponse(www.text), rowNum, cameraForward);
            rowNum++;
        }
        yield return(new WaitForSeconds(5f));

        buttonText.transform.parent.gameObject.SetActive(true);
    }
Esempio n. 3
0
    IEnumerator PictureRoutine()
    {
        buttonText.transform.parent.gameObject.SetActive(false);
        string query = buttonText.text;

        /* Make query URL-friendly */
        query = WWW.EscapeURL(query + " design");
        pictureFactory.DeleteOldPictures();

        /* Save CameraForward vector for later use when loading pictures */
        Vector3 CameraForward = Camera.main.transform.forward;

        int RowNum = 1;

        /* Loop through 10 at a time, as this is the upper limit for # searches in Google API */
        for (int i = 1; i < 60; i += 10)
        {
            string url = "https://www.googleapis.com/customsearch/v1?q=" + query +
                         "&cx=003623769318945352620%3Aiovyyjqdnok&filter=1&num=10&searchType=image&start=" + i + "&fields=items%2Flink&key=" + API_KEY;
            WWW www = new WWW(url);
            yield return(www);

            pictureFactory.CreateImages(ParseResponse(www.text), RowNum, CameraForward);
            RowNum++;
        }
        yield return(new WaitForSeconds(5f));

        buttonText.transform.parent.gameObject.SetActive(true);
    }
Esempio n. 4
0
    IEnumerator PictureRoutine()
    {
        string query = buttonText.text;

        buttonText.transform.parent.gameObject.SetActive(false);
        query = WWW.EscapeURL(query + " images");
        pictureFactory.DeleteOldPictures();
        Vector3 cameraForward = Camera.main.transform.forward;

        int rowNum = 1;

        for (int i = 1; i <= 60; i += 10)
        {
            string url = "https://www.googleapis.com/customsearch/v1?q=" + query + "&cx=016925171207090246864%3Aowoq0xec9s0&filter=1&num=10&searchType=image&start=" + i + "&fields=items%2Flink&key=" + API_KEY;
            WWW    www = new WWW(url);

            yield return(www);

            pictureFactory.CreateImages(ParseResponse(www.text), rowNum, cameraForward);
            rowNum++;
        }
        yield return(new WaitForSeconds(5f));

        buttonText.transform.parent.gameObject.SetActive(true);
    }
Esempio n. 5
0
    IEnumerator PictureRoutine()
    {
        buttonText.transform.parent.gameObject.SetActive(false);
        string query = buttonText.text;

        query = WWW.EscapeURL(query);
        pictureFactory.DeleteOldPictures();
        Vector3 cameraForward = Camera.main.transform.forward;

        int rowNum = 1;

        for (int i = 1; i <= 60; i += 5)
        {
            string url = "https://www.googleapis.com/customsearch/v1?q=pyramids&cx=000840476634705069223%3Arw0zula5h_0&filter=1&num=10&searchType=image&start=" + i + "1&fields=items%2Flink&key=" + API_KEY;

            WWW www = new WWW(url);
            yield return(www);

            pictureFactory.CreateImages(ParseResponse(www.text), rowNum, cameraForward);
            rowNum++;
        }
        yield return(new WaitForSeconds(5f));

        buttonText.transform.parent.gameObject.SetActive(true);
    }