Esempio n. 1
0
        public void requestAvatar(string url)
        {
            string access_token = EditorPrefs.GetString(accessTokenKey);

            if (access_token == null || access_token.Length < 30)
            {
                Debug.Log("Access token is invalid or inexistant");
                return;
            }

            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", "Bearer " + access_token);
            SketchfabRequest request = new SketchfabRequest(url, headers);

            request.setCallback(handleAvatar);
            SketchfabPlugin.getAPI().registerRequest(request);
        }
Esempio n. 2
0
        void handleSearch(string response)
        {
            JSONNode  json  = Utils.JSONParse(response);
            JSONArray array = json["results"].AsArray;

            if (array == null)
            {
                return;
            }

            if (json["cursors"] != null)
            {
                if (json["cursors"]["next"].AsInt == 24)
                {
                    _prevCursor = "";
                }
                else if (_nextCursor != "null" && _nextCursor != "")
                {
                    _prevCursor = int.Parse(_nextCursor) - 24 + "";
                }

                _nextCursor = json["cursors"]["next"];
            }

            // First model fetch from uid
            foreach (JSONNode node in array)
            {
                _resultUids.Add(node["uid"]);
                if (!_sketchfabModels.ContainsKey(node["uid"]))
                {
                    // Add model to results
                    SketchfabModel model = new SketchfabModel(node, _defaultThumbnail);
                    model.previewUrl = getThumbnailUrl(node, 768);
                    _sketchfabModels.Add(node["uid"], model);

                    // Request model thumbnail
                    SketchfabRequest request = new SketchfabRequest(getThumbnailUrl(node));
                    request.setCallback(handleThumbnail);
                    _api.registerRequest(request);
                }
            }
            _isFetching = false;
            Refresh();
        }
 public SketchfabAPI(string uploadSource = "")
 {
     _publisher = new SketchfabRequest(uploadSource);
     _publisher.setResponseCallback(HandleRequestResponse);
 }
Esempio n. 4
0
 // Instanciate requests (need to use limit and buffer)
 public void registerRequest(SketchfabRequest request)
 {
     checkValidity();
     _requests.Add(request);
     request.send();
 }