void Start() { // Create a new request PolyListAssetsRequest req = new PolyListAssetsRequest(); // Search by keywords req.keywords = "frosted donut"; // Make the request with a callback function PolyApi.ListAssets(req, GetDonuts); }
private void Start() { //Initialize page = 0; req = new PolyListAssetsRequest(); //Get Featured Models PolyApi.ListAssets(PolyListAssetsRequest.Featured(), LoadModels); }
//////////////////////////////////////// // // List Assets public void ListAssets(int count, Action <List <PolyAsset> > callback) { PolyListAssetsRequest request = PolyListAssetsRequest.Featured(); request.maxComplexity = PolyMaxComplexityFilter.SIMPLE; request.pageSize = count; PolyApi.ListAssets(request, (result) => { OnAssetsListed(result, callback); }); }
public void DefaultSearch(OnActorableSearchResult resultCallback) { PolyListAssetsRequest req = new PolyListAssetsRequest(); req.curated = true; req.maxComplexity = PolyMaxComplexityFilter.MEDIUM; req.orderBy = PolyOrderBy.BEST; req.pageSize = MAX_ASSETS_RETURNED; PolyApi.ListAssets(req, (result) => PolySearchCallback(result, resultCallback, null)); }
void Start() { m_cameraTransform = GameObject.FindWithTag("MainCamera").transform; asset_id_name_list = new List <KeyValuePair <string, string> >(); asset_thumbnail_list = new List <KeyValuePair <string, Texture2D> >(); Debug.Log("Requesting List of Assets..."); // list featured assets PolyApi.ListAssets(PolyListAssetsRequest.Featured(), FeaturedAssetListCallback); //PolyAssetSearchQuery(searchKeyword); }
public void LoadAssets() { PolyListAssetsRequest polyRequest = PolyListAssetsRequest.Featured(); polyRequest.pageSize = pageSize; polyRequest.curated = true; polyRequest.orderBy = PolyOrderBy.BEST; polyRequest.pageToken = pageination; PolyApi.ListAssets(polyRequest, LoadAssetsCallback); }
private void Start() { // Request a list of featured assets from Poly. Debug.Log("Getting featured assets..."); statusText.text = "Requesting..."; PolyListAssetsRequest request = PolyListAssetsRequest.Featured(); // Limit requested models to those of medium complexity or lower. request.maxComplexity = PolyMaxComplexityFilter.MEDIUM; PolyApi.ListAssets(request, ListAssetsCallback); }
private void CmdList(string[] args) { PolyListAssetsRequest req; if (args.Length > 0 && args[0] == "featured") { // Default list request (featured). req = PolyListAssetsRequest.Featured(); } else if (args.Length > 0 && args[0] == "latest") { // Default list request (latest). req = PolyListAssetsRequest.Latest(); } else { // Custom list request. req = new PolyListAssetsRequest(); } // Mutate the request according to parameters. req.category = GetEnumOpt(args, "-c", req.category); req.curated = HasOpt(args, "-k") ? true : req.curated; req.keywords = GetOpt(args, "-s", req.keywords); req.maxComplexity = GetEnumOpt(args, "--maxc", req.maxComplexity); req.orderBy = GetEnumOpt(args, "-o", req.orderBy); req.pageSize = GetIntOpt(args, "-p", req.pageSize); req.pageToken = GetOpt(args, "--pt", req.pageToken); // FormatFilter is weird because it's nullable, so we have to test before trying to parse: if (HasOpt(args, "-f")) { req.formatFilter = GetEnumOpt(args, "-f", PolyFormatFilter.BLOCKS /* not used */); } if (HasOpt(args, "--dry")) { // Dry run mode. PrintLn(req.ToString()); return; } // Send the request. hasRunListCommand = true; PrintLn("Sending list request... Please wait."); PolyApi.ListAssets(req, (PolyStatusOr <PolyListAssetsResult> res) => { if (!res.Ok) { PrintLn("Request ERROR: " + res.Status); return; } currentResults = res.Value.assets; CmdShow(new string[] {}); }); }
/// <summary> /// As documented in PolyClient.ListAssets. /// </summary> public void ListAssets(PolyListAssetsRequest listAssetsRequest, PolyApi.ListAssetsCallback callback) { polyClient.SendRequest(listAssetsRequest, (PolyStatus status, PolyListAssetsResult polyListResult) => { if (status.ok) { ProcessRequestResult(polyListResult, callback); } else { callback(new PolyStatusOr <PolyListAssetsResult>(PolyStatus.Error(status, "Request failed"))); } }); }
// move to new class? (e.g. pallette manager) private void GetPaletteThumbnails() { // display featured asset thumbnais Debug.Log("Getting featured asset thumbnails..."); statusText.text = "Requesting..."; PolyListAssetsRequest request = PolyListAssetsRequest.Featured(); // Limit requested models to those of medium complexity or lower. request.maxComplexity = PolyMaxComplexityFilter.MEDIUM; PolyApi.ListAssets(request, ListAssetsCallback); // setup add asset buttons button1.onClick.AddListener(delegate { ImportAsset(0); }); button2.onClick.AddListener(delegate { ImportAsset(1); }); button3.onClick.AddListener(delegate { ImportAsset(2); }); button4.onClick.AddListener(delegate { ImportAsset(3); }); }
void StartDownload() { Debug.Log("Getting featured assets..."); if (_statusText != null) { _statusText.text = "Requesting..."; } didCompleteRequest = false; PolyListAssetsRequest request = PolyListAssetsRequest.Featured(); // Limit requested models to those of medium complexity or lower. request.maxComplexity = PolyMaxComplexityFilter.SIMPLE; PolyApi.ListAssets(request, ListAssetsCallback); Invoke("CheckTimeout", 10f); }
/// <summary> /// Starts a new request. If there is already an existing request in progress, it will be cancelled. /// </summary> /// <param name="request">The request parameters; can be either a ListAssetsRequest or /// a PolyListUserAssetsRequest.</param> /// <param name="callback"> The callback to invoke when the request finishes.</param> private void StartRequest(PolyRequest request, Action <PolyStatusOr <PolyListAssetsResult> > callback) { int thisQueryId = PrepareForNewQuery(); // for the closure below. currentRequest = request; if (request is PolyListAssetsRequest) { PolyListAssetsRequest listAssetsRequest = request as PolyListAssetsRequest; PolyApi.ListAssets(listAssetsRequest, (PolyStatusOr <PolyListAssetsResult> result) => { // Only process result if this is indeed the most recent query that we issued. // If we have issued another query since (in which case thisQueryId < queryId), // then ignore the result. if (thisQueryId == queryId && callback != null) { callback(result); } }); } else if (request is PolyListUserAssetsRequest) { PolyListUserAssetsRequest listUserAssetsRequest = request as PolyListUserAssetsRequest; PolyApi.ListUserAssets(listUserAssetsRequest, (PolyStatusOr <PolyListAssetsResult> result) => { if (thisQueryId == queryId && callback != null) { callback(result); } }); } else if (request is PolyListLikedAssetsRequest) { PolyListLikedAssetsRequest listLikedAssetsRequest = request as PolyListLikedAssetsRequest; PolyApi.ListLikedAssets(listLikedAssetsRequest, (PolyStatusOr <PolyListAssetsResult> result) => { if (thisQueryId == queryId && callback != null) { callback(result); } }); } else { Debug.LogError("Request failed. Must be either a PolyListAssetsRequest or PolyListUserAssetsRequest"); } }
public void PolyAssetSearchQuery(string searchKey) { PolyListAssetsRequest req = new PolyListAssetsRequest(); // Search by keyword: req.keywords = searchKey; // Only curated assets: req.curated = true; // Limit complexity to simple low poly. req.maxComplexity = PolyMaxComplexityFilter.COMPLEX; // Only Blocks objects. //req.formatFilter = PolyFormatFilter.BLOCKS; // Order from best to worst. req.orderBy = PolyOrderBy.BEST; // Up to 20 results per page. req.pageSize = 20; // Send the request. PolyApi.ListAssets(req, SearchAssetListCallback); }
public void onCategorySelected(string category) { Debug.Log(category + "::::" + PolyCategory.TRANSPORT); PolyListAssetsRequest req = new PolyListAssetsRequest(); // Search by keyword: req.category = PolyCategory.TRANSPORT; //req.keywords = "tree"; // Only curated assets: req.curated = true; // Limit complexity to medium. req.maxComplexity = PolyMaxComplexityFilter.MEDIUM; // Only Blocks objects. req.formatFilter = PolyFormatFilter.BLOCKS; // Order from best to worst. req.orderBy = PolyOrderBy.BEST; // Up to 20 results per page. //req.pageSize = 20; PolyApi.ListAssets(req, CallListAssetsCallbackEvent); }
public void onCustomRequestsButtonClicked() { PolyListAssetsRequest req = new PolyListAssetsRequest(); // Search by keyword: req.keywords = "tree"; // Only curated assets: req.curated = true; // Limit complexity to medium. req.maxComplexity = PolyMaxComplexityFilter.MEDIUM; // Only Blocks objects. req.formatFilter = PolyFormatFilter.BLOCKS; // Order from best to worst. req.orderBy = PolyOrderBy.BEST; // Up to 20 results per page. req.pageSize = 20; // Send the request. //PolyApi.ListAssets(req, MyCallback); }
public void getInitialAssets(bool isPoly) { polyDescription = isPoly; FirebaseHandler firebaseHandler = FindObjectOfType <FirebaseHandler>(); m_cameraTransform = GameObject.FindWithTag("MainCamera").transform; asset_id_name_list = new List <KeyValuePair <string, string> >(); asset_thumbnail_list = new List <KeyValuePair <string, Texture2D> >(); // list featured assets if (isPoly) { PolyApi.ListAssets(PolyListAssetsRequest.Featured(), FeaturedAssetListCallback); } else { firebaseHandler.getElements(HandleFirebaseObjects); } }
public void Search(string searchstring, OnActorableSearchResult resultCallback, System.Action <bool> onComplete) { // Special case: if the search string is a URL of a Poly asset, just return it. if (searchstring.Contains("poly.google.com/")) { SearchByPolyUrl(searchstring, resultCallback, onComplete); return; } PolyListAssetsRequest req = new PolyListAssetsRequest(); req.curated = true; req.keywords = searchstring; req.maxComplexity = PolyMaxComplexityFilter.MEDIUM; req.orderBy = PolyOrderBy.BEST; req.pageSize = MAX_ASSETS_RETURNED; PolyApi.ListAssets(req, (result) => PolySearchCallback(result, resultCallback, onComplete)); }
PolyListAssetsRequest CreateRequest(string keyword) { PolyListAssetsRequest req = new PolyListAssetsRequest { // Search by keyword: keywords = keyword, // Only curated assets: curated = true, // Limit complexity to medium. maxComplexity = PolyMaxComplexityFilter.MEDIUM, // Only Blocks objects. formatFilter = PolyFormatFilter.BLOCKS, // Order from best to worst. orderBy = PolyOrderBy.BEST, // Up to 20 results per page. pageSize = 1 }; return(req); }
public RequestHandler(PolyOrderBy orderBy, PolyMaxComplexityFilter complexity, PolyFormatFilter?format, PolyCategory category, int requestSize, List <PolyGridAsset> assets, Transform container, Action <string> listCallback, string nextPageToken = null) { m_Assets = assets; m_Container = container; m_ListCallback = listCallback; var request = new PolyListAssetsRequest { orderBy = orderBy, maxComplexity = complexity, formatFilter = format, category = category }; request.pageToken = nextPageToken; request.pageSize = requestSize; PolyApi.ListAssets(request, ListAssetsCallback); }
public void SearchAssetandSpawn(string name) { PolyListAssetsRequest req = new PolyListAssetsRequest(); // Search by keyword: req.keywords = name; // Only curated assets: req.curated = true; // Limit complexity to medium. // req.maxComplexity = PolyMaxComplexityFilter.MEDIUM; // Only Blocks objects. // req.formatFilter = PolyFormatFilter.; // Order from best to worst. req.orderBy = PolyOrderBy.BEST; // Up to 20 results per page. // req.pageSize = 20; // Send the request. PolyApi.ListAssets(req, MyCallback); }
/// <summary> /// Return a Poly search URL representing a ListAssetsRequest. /// </summary> private static string MakeSearchUrl(PolyListAssetsRequest listAssetsRequest) { StringBuilder sb = new StringBuilder(); sb.Append(BASE_URL) .Append("/v1/assets") .AppendFormat("?key={0}", WWW.EscapeURL(PolyMainInternal.Instance.apiKey)); if (listAssetsRequest.formatFilter != null) { sb.AppendFormat("&format={0}", WWW.EscapeURL(FORMAT_FILTER[listAssetsRequest.formatFilter.Value])); } if (listAssetsRequest.keywords != null) { sb.AppendFormat("&keywords={0}", WWW.EscapeURL(listAssetsRequest.keywords)); } if (listAssetsRequest.category != PolyCategory.UNSPECIFIED) { sb.AppendFormat("&category={0}", WWW.EscapeURL(CATEGORIES[listAssetsRequest.category])); } if (listAssetsRequest.curated) { sb.Append("&curated=true"); } if (listAssetsRequest.maxComplexity != PolyMaxComplexityFilter.UNSPECIFIED) { sb.AppendFormat("&max_complexity={0}", WWW.EscapeURL(MAX_COMPLEXITY[listAssetsRequest.maxComplexity])); } sb.AppendFormat("&order_by={0}", WWW.EscapeURL(ORDER_BY[listAssetsRequest.orderBy])); sb.AppendFormat("&page_size={0}", listAssetsRequest.pageSize.ToString()); if (listAssetsRequest.pageToken != null) { sb.AppendFormat("&page_token={0}", WWW.EscapeURL(listAssetsRequest.pageToken)); } return(sb.ToString()); }
public void SearchAPI() { if (searchField.text.Length > 0) { // Create a new request PolyListAssetsRequest request = new PolyListAssetsRequest(); // Set request parameters request.keywords = searchField.text; request.pageSize = (int)(sizeSlider.value); PolyCategory category = (PolyCategory)categoryDropdown.value; request.category = category; PolyOrderBy order = (PolyOrderBy)orderDropdown.value; request.orderBy = order; // Make the request and pass result to callback function PolyApi.ListAssets(request, HandleResults); } }
public void onCategorySelected(string category) { selectedCategoryName.text = category; Debug.Log("Categrou Nmae::::::" + selectedCategoryName.text); selectedCategoryName.gameObject.SetActive(true); PolyListAssetsRequest req = new PolyListAssetsRequest(); if (category == PolyCategory.ANIMALS.ToString()) { req.category = PolyCategory.ANIMALS; } else if (category == PolyCategory.ARCHITECTURE.ToString()) { req.category = PolyCategory.ARCHITECTURE; } else if (category == PolyCategory.ART.ToString()) { req.category = PolyCategory.ART; } else if (category == PolyCategory.FOOD.ToString()) { req.category = PolyCategory.FOOD; } else if (category == PolyCategory.NATURE.ToString()) { req.category = PolyCategory.NATURE; } else if (category == PolyCategory.OBJECTS.ToString()) { req.category = PolyCategory.OBJECTS; } else if (category == PolyCategory.PEOPLE.ToString()) { req.category = PolyCategory.PEOPLE; } else if (category == PolyCategory.PLACES.ToString()) { req.category = PolyCategory.PLACES; } else if (category == PolyCategory.TECH.ToString()) { req.category = PolyCategory.TECH; } else if (category == PolyCategory.TRANSPORT.ToString()) { req.category = PolyCategory.TRANSPORT; } else { req.category = PolyCategory.UNSPECIFIED; } // Search by keyword: //req.category = PolyCategory.TRANSPORT; //req.keywords = "tree"; // Only curated assets: req.curated = true; // Limit complexity to medium. req.maxComplexity = PolyMaxComplexityFilter.MEDIUM; // Only Blocks objects. req.formatFilter = PolyFormatFilter.BLOCKS; // Order from best to worst. req.orderBy = PolyOrderBy.BEST; // Up to 20 results per page. //req.pageSize = 20; //PolyApi.ListAssets(PolyListAssetsRequest.Featured(), CallListAssetsCallbackEvent); PolyApi.ListAssets(req, CallListAssetsCallbackEvent); }
public async Task <ScoredSearchResult> SearchPoly(string term) { Debug.Log("Searching Poly for term: " + term); var request = new PolyListAssetsRequest(); request.orderBy = PolyOrderBy.BEST; request.keywords = term; request.curated = true; PolyListAssetsResult result = null; bool error = false; PolyApi.ListAssets(request, response => { if (response.Ok) { result = response.Value; } else { error = true; } }); while (result == null && !error) //TODO: Add Timeout to avoid infinite loop! { await Task.Delay(50); } await new WaitForBackgroundThread(); PolyAsset bestAsset = null; double bestScore = double.MinValue; if (result != null) { foreach (var asset in result.assets) { //get how related it is to the search term //if doesn't exist in concept net, only accept exact matches (or lev dists <2) //made by poly is * 1.5 multiplier (can tweak) double score = -1; if (asset.displayName.ToLower().Equals(term)) { score = 1; } else { score = _conceptNet.GetRelationScore(asset.displayName.ToLower(), term); } Debug.Log(asset.displayName + " by: " + asset.authorName + " (" + score + ") ");; if (asset.authorName.Contains("Google")) { score = score * 1.75; } if (score > bestScore) { bestScore = score; bestAsset = asset; } } } if (bestAsset != null) { Debug.Log( String.Format("Term: {0}, Asset: {1}, Score: {2}", term, bestAsset.displayName + " by: " + bestAsset.authorName, bestScore)); } else { Debug.Log("No results for term: " + term); } var bestResult = new ScoredSearchResult(); bestResult.score = bestScore; bestResult.polyAsset = bestAsset; await new WaitForUpdate(); return(bestResult); }
public void onButtonClick() { PolyApi.ListAssets(PolyListAssetsRequest.Featured(), InitialiseUIContent); }
void LoadAsset(string keyword) { PolyListAssetsRequest polyListAssetsRequest = CreateRequest(keyword); PolyApi.ListAssets(polyListAssetsRequest, HandleRequest); }
public void onListAssetsButtonClicked() { PolyApi.ListAssets(PolyListAssetsRequest.Featured(), CallListAssetsCallbackEvent); }