예제 #1
0
        private void publishModel(string zipPath)
        {
            byte[]  data     = File.ReadAllBytes(zipPath);
            WWWForm postForm = new WWWForm();
            Dictionary <string, string> parameters = buildParameterDictWWW();

            foreach (string param in parameters.Keys)
            {
                postForm.AddField(param, parameters[param]);
            }

            postForm.AddBinaryData("modelFile", data, zipPath, "application /zip");
            postForm.AddField("source", "unity-exporter");

            UnityWebRequest ure = UnityWebRequest.Post(SketchfabPlugin.Urls.postModel, postForm);

            ure.SetRequestHeader("Authorization", _logger.getHeader()["Authorization"]);
            SketchfabRequest request = new SketchfabRequest(ure);

            request.setCallback(onModelPublished);
            request.setProgressCallback(handleUploadCallback);
            request.setFailedCallback(handleUploadError);
            _api.registerRequest(request);
            _uploadRequest = request;
        }
예제 #2
0
        public void fetchGLTFModel(string uid, RefreshCallback fetchedCallback, Dictionary <string, string> headers)
        {
            _isFeching = true;
            string url = SketchfabPlugin.Urls.modelEndPoint + "/" + uid + "/download";

            _modelRequest = new SketchfabRequest(url, headers);
            _modelRequest.setCallback(handleDownloadAPIResponse);
            _modelRequest.setFailedCallback(handleFailFetchDownloadURl);
            _window._browserManager._api.registerRequest(_modelRequest);
        }
예제 #3
0
        public void requestUserData()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", "Bearer " + EditorPrefs.GetString(accessTokenKey));
            SketchfabRequest request = new SketchfabRequest(SketchfabPlugin.Urls.userMe, headers);

            request.setCallback(handleUserData);
            request.setFailedCallback(logout);
            SketchfabPlugin.getAPI().registerRequest(request);
        }
예제 #4
0
        public void requestAccessToken(string user_name, string user_password)
        {
            List <IMultipartFormSection> formData = new List <IMultipartFormSection>();

            formData.Add(new MultipartFormDataSection("username", user_name));
            formData.Add(new MultipartFormDataSection("password", user_password));

            SketchfabRequest tokenRequest = new SketchfabRequest(SketchfabPlugin.Urls.oauth, formData);

            tokenRequest.setCallback(handleGetToken);
            tokenRequest.setFailedCallback(onLoginFailed);
            SketchfabPlugin.getAPI().registerRequest(tokenRequest);
        }