Skip to content

Unity3d duckduckgo-images-api for retrieving image search results with c# code

License

Notifications You must be signed in to change notification settings

bilal-arikan/duckduckgo-images-api-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duckduckgo-images-api-unity

Unity3d wrapper for duckduckgo-images-api

Screenshot

Alt text

How to Import:

  • Add to manifest.json
"com.arikan.duckduckgo.images" : "https://github.com/bilal-arikan/duckduckgo-images-api-unity.git",

How to Use:

DuckDuckGo.Search(
    "banana",           // search input 
    SafeSearch.Off,     // safesearch
    0,                  // page 
    "us-en",            // locations
    OnSearchCallback    // callback
);  

void OnSearchCallback(ImageSearchResult result)
{
    if (result == null)
    {
        Debug.LogError("Result Null", this);
        return;
    }

    Debug.Log($"Result Count: " + result.results.Count, this);
    Debug.Log("First Result:\n" + JsonUtility.ToJson(result.results[0], true), this);
    foreach (var item in result.results.Take(ShowMaxResultAmount))
    {
        var request = UnityWebRequestTexture.GetTexture(item.thumbnail).SendWebRequest();
        request.completed +=
        (ao) =>
        {
            if (ao.isDone)
            {
                RawImage image = Instantiate(ResultImagePrefab, ResultsLayout.transform);
                image.texture = DownloadHandlerTexture.GetContent(request.webRequest);
            }
        };
    }
}

About

Unity3d duckduckgo-images-api for retrieving image search results with c# code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages