コード例 #1
0
        /*
         * Searches the asset store for assets and passes the results to DoneCallback
         */
        internal static AsyncHTTPClient SearchAssets(string searchString, string[] requiredClassNames, string[] assetLabels,
                                                     List <SearchCount> counts,
                                                     AssetStoreSearchResults.Callback callback)
        {
            string offsets    = "";
            string limits     = "";
            string groupNames = "";
            string delim      = "";

            foreach (SearchCount v in counts)
            {
                offsets    += delim + v.offset;
                limits     += delim + v.limit;
                groupNames += delim + v.name;
                delim       = ",";
            }

            // If one af the class names is "MonoScript" then also include "Script" since
            // that is what asset store expects
            if (Array.Exists(requiredClassNames, (string a) => { return(a.Equals("MonoScript", StringComparison.OrdinalIgnoreCase)); }))
            {
                Array.Resize(ref requiredClassNames, requiredClassNames.Length + 1);
                requiredClassNames[requiredClassNames.Length - 1] = "Script";
            }

            string url = string.Format("{0}&q={1}&c={2}&l={3}&O={4}&N={5}&G={6}",
                                       APISearchUrl("/search/assets"),
                                       System.Uri.EscapeDataString(searchString),
                                       System.Uri.EscapeDataString(string.Join(",", requiredClassNames)),
                                       System.Uri.EscapeDataString(string.Join(",", assetLabels)),
                                       offsets, limits, groupNames);

            //Debug.Log(url);
            //Debug.Log("session key " + ActiveOrUnauthSessionID + GetToken());
            AssetStoreSearchResults r = new AssetStoreSearchResults(callback);

            return(CreateJSONRequest(url, delegate(AssetStoreResponse ar) { r.Parse(ar); }));
        }
コード例 #2
0
        internal static AsyncHTTPClient SearchAssets(string searchString, string[] requiredClassNames, string[] assetLabels, List <AssetStoreClient.SearchCount> counts, AssetStoreResultBase <AssetStoreSearchResults> .Callback callback)
        {
            string text  = string.Empty;
            string text2 = string.Empty;
            string text3 = string.Empty;
            string text4 = string.Empty;

            foreach (AssetStoreClient.SearchCount current in counts)
            {
                text  = text + text4 + current.offset;
                text2 = text2 + text4 + current.limit;
                text3 = text3 + text4 + current.name;
                text4 = ",";
            }
            if (Array.Exists <string>(requiredClassNames, (string a) => a.Equals("MonoScript", StringComparison.OrdinalIgnoreCase)))
            {
                Array.Resize <string>(ref requiredClassNames, requiredClassNames.Length + 1);
                requiredClassNames[requiredClassNames.Length - 1] = "Script";
            }
            string url = string.Format("{0}&q={1}&c={2}&l={3}&O={4}&N={5}&G={6}", new object[]
            {
                AssetStoreClient.APISearchUrl("/search/assets"),
                Uri.EscapeDataString(searchString),
                Uri.EscapeDataString(string.Join(",", requiredClassNames)),
                Uri.EscapeDataString(string.Join(",", assetLabels)),
                text,
                text2,
                text3
            });
            AssetStoreSearchResults r = new AssetStoreSearchResults(callback);

            return(AssetStoreClient.CreateJSONRequest(url, delegate(AssetStoreResponse ar)
            {
                r.Parse(ar);
            }));
        }