Esempio n. 1
0
        public void requestCanPrivate()
        {
            SketchfabRequest canPrivateRequest = new SketchfabRequest(SketchfabPlugin.Urls.userAccount, getHeader());

            canPrivateRequest.setCallback(onCanPrivate);
            SketchfabPlugin.getAPI().registerRequest(canPrivateRequest);
        }
Esempio n. 2
0
        // Manager integrity and reset
        private void checkValidity()
        {
            SketchfabPlugin.checkValidity();
            if (_api == null)
            {
                _api = SketchfabPlugin.getAPI();
            }

            if (_resultUids == null)
            {
                _resultUids = new List <string>();
            }

            if (_sketchfabModels == null)
            {
                _sketchfabModels = new Dictionary <string, SketchfabModel>();
            }

            if (_categories == null)
            {
                fetchCategories();
            }

            if (_importer == null)
            {
                _importer = new SketchfabImporter(ImportProgress, ImportFinish);
            }
        }
Esempio n. 3
0
        void searchCursor(string cursorUrl)
        {
            _hasFetchedPreviews = false;
            SketchfabRequest request = new SketchfabRequest(cursorUrl, SketchfabPlugin.getLogger().getHeader());

            request.setCallback(handleSearch);
            _api.registerRequest(request);
        }
Esempio n. 4
0
 private void Update()
 {
     SketchfabPlugin.Update();
     if (_importer != null)
     {
         _importer.Update();
     }
 }
        void startSearch(string cursor = "")
        {
            _hasFetchedPreviews = false;
            SketchfabRequest request = new SketchfabRequest(_lastQuery + cursor, SketchfabPlugin.getLogger().getHeader());

            request.setCallback(handleSearch);
            _api.registerRequest(request);
        }
Esempio n. 6
0
        void requestArchive()
        {
            SketchfabRequest request = new SketchfabRequest(_archiveUrl);

            request.setCallback(handleArchive);
            request.setProgressCallback(handleDownloadCallback);
            SketchfabPlugin.getAPI().registerRequest(request);
        }
        void requestArchive(string modelUrl)
        {
            SketchfabRequest request = new SketchfabRequest(_currentModel.tempDownloadUrl);

            request.setCallback(handleArchive);
            request.setProgressCallback(handleDownloadCallback);
            SketchfabPlugin.getAPI().registerRequest(request);
        }
Esempio n. 8
0
 private void Initialize()
 {
     SketchfabPlugin.Initialize();
     _importer               = new SketchfabImporter(UpdateProgress, OnFinishImport);
     _unzippedFiles          = new List <string>();
     _unzipDirectory         = Application.temporaryCachePath + "/unzip";
     _defaultImportDirectory = Application.dataPath + "/Import";
     _importDirectory        = _defaultImportDirectory;
     _importFilePath         = _sourceFileHint;
     _ui = SketchfabPlugin.getUI();
 }
Esempio n. 9
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);
        }
Esempio n. 10
0
 private void checkValidity()
 {
     SketchfabPlugin.checkValidity();
     if (_ui == null)
     {
         _ui = new SketchfabUI();
     }
     if (_importer == null)
     {
         Initialize();
     }
 }
Esempio n. 11
0
        //UI
        void OnGUI()
        {
            checkValidity();
            if (_ui == null || !_ui._isInitialized)
            {
                GUILayout.Label("Initializing ui...");
                return;
            }

            SketchfabPlugin.displayHeader();

            GUILayout.Space(SketchfabPlugin.SPACE_SIZE);

            showModelProperties();

            GUILayout.Space(SketchfabPlugin.SPACE_SIZE);
            showOptions();

            bool enable = updateExporterStatus();

            if (enable)
            {
                GUI.color = SketchfabUI.SKFB_BLUE;
            }
            else
            {
                GUI.color = Color.white;
            }

            GUI.enabled = enable;
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(status, GUILayout.Width(250), GUILayout.Height(40)))
            {
                if (!enable)
                {
                    EditorUtility.DisplayDialog("Error", status, "Ok");
                }
                else
                {
                    proceedToExportAndUpload();
                }
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUI.color = Color.white;

            SketchfabPlugin.displayFooter();
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
 private void checkValidity()
 {
     if (_ui == null)
     {
         _ui = SketchfabPlugin.getUI();
     }
     if (_api == null)
     {
         _api = SketchfabPlugin.getAPI();
     }
     if (_logger == null)
     {
         _logger = SketchfabPlugin.getLogger();
     }
 }
        public void displayModelPage(SketchfabModel model, SketchfabBrowser browser)
        {
            _window = browser;
            if (_currentModel == null || model.uid != _currentModel.uid)
            {
                _currentModel    = model;
                _prefabName      = GLTFUtils.cleanName(_currentModel.name).Replace(" ", "_");
                _importDirectory = Application.dataPath + "/Import/" + _prefabName.Replace(" ", "_");
            }
            else
            {
                _currentModel = model;
            }

            _ui  = SketchfabPlugin.getUI();
            show = true;
        }
Esempio n. 15
0
        // UI
        void OnGUI()
        {
            checkValidity();
            SketchfabPlugin.displayHeader();

            if (_currentUid.Length > 0)
            {
                displaySeparatedModelPage();
            }

            displaySearchOptions();
            displayNextPrev();
            _scrollView = GUILayout.BeginScrollView(_scrollView);
            displayResults();
            GUILayout.EndScrollView();

            SketchfabPlugin.displayFooter();
        }
Esempio n. 16
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);
        }
        // UI
        void OnGUI()
        {
            checkValidity();
            SketchfabPlugin.displayHeader();

            if (_currentUid.Length > 0)
            {
                displaySeparatedModelPage();
            }

            displaySearchOptions();
            displayNextPrev();
            _scrollView = GUILayout.BeginScrollView(_scrollView);
            displayResults();
            GUILayout.EndScrollView();

            if (_searchInIndex == SEARCH_IN.MY_STORE_PURCHASES && !_browserManager.hasResults())
            {
                if (_query.Length > 0)
                {
                    displayCenteredMessage("There is no result for '" + _query + "' in your purchases.");
                }
                else
                {
                    displayCenteredMessage("It looks like you didn't do any purchase yet on Sketchfab Store");
                }
            }

            if (_searchInIndex == SEARCH_IN.MY_MODELS && _logger.isUserLogged() && !_logger.canAccessOwnModels())
            {
                if (_query.Length > 0)
                {
                    displayCenteredMessage("There is no result for '" + _query + "' in your .");
                }
                else
                {
                    displayCenteredMessage("It look like you don't have any model or your plan doesn't allow you to access them");
                }

                displayFooter();
            }

            SketchfabPlugin.displayFooter();
        }
Esempio n. 18
0
        void displaySearchBox()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Search:", GUILayout.Width(80));
            GUI.SetNextControlName("SearchTextField");
            _query = EditorGUILayout.TextField(_query, GUILayout.Width(350));

            if (Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "SearchTextField")
            {
                triggerSearch();
            }

            if (GUILayout.Button("Search", GUILayout.Width(120)))
            {
                triggerSearch();
            }

            GUILayout.FlexibleSpace();
            bool       previous = _myModels;
            GUIContent content  = _logger.isUserBasic() ? new GUIContent("My Models", SketchfabUI.getPlanIcon("pro")) : new GUIContent("My Models");

            bool previousState = GUI.enabled;

            GUI.enabled = SketchfabPlugin.getLogger().isUserLogged();
            _myModels   = GUILayout.Toggle(_myModels, content, GUILayout.Height(18));
            GUI.enabled = previousState;

            if (_myModels != previous)
            {
                if (_myModels)
                {
                    resetFilersOwnModels();
                }
                else
                {
                    resetFilters();
                }

                triggerSearch();
            }

            GUILayout.EndHorizontal();
        }
Esempio n. 19
0
        private void checkValidity()
        {
            if (_browserManager == null)
            {
                _browserManager = new SketchfabBrowserManager(OnRefreshUpdate, true);
                resetFilters();
                _currentUid      = "";
                _categoryName    = "";
                _categoriesNames = new string[0];

                // Setup sortBy
                _sortBy    = new string[] { "Relevance", "Likes", "Views", "Recent" };
                _polyCount = new string[] { "Any", "Up to 10k", "10k to 50k", "50k to 100k", "100k to 250k", "250k +" };
                this.Repaint();
                GL.sRGBWrite = true;
            }

            SketchfabPlugin.checkValidity();
            _ui     = SketchfabPlugin.getUI();
            _logger = SketchfabPlugin.getLogger();
        }
Esempio n. 20
0
        // UI
        private void OnGUI()
        {
            checkValidity();
            SketchfabPlugin.displayHeader();

            if (_ui == null)
            {
                return;
            }

            handleDragNDrop();

            _scrollView = GUILayout.BeginScrollView(_scrollView);
            displayInputInfos();
            displayImportDirectory();
            displayImportOptions();
            GUILayout.EndScrollView();

            displayImportButton();

            SketchfabPlugin.displayFooter();
        }
        // Manager integrity and reset
        private void checkValidity()
        {
            SketchfabPlugin.checkValidity();
            if (_api == null)
            {
                _api = SketchfabPlugin.getAPI();
            }

            if (_sketchfabModels == null)
            {
                _sketchfabModels = new OrderedDictionary();
            }

            if (_categories == null)
            {
                fetchCategories();
            }

            if (_importer == null)
            {
                _importer = new SketchfabImporter(ImportProgress, ImportFinish);
            }
        }
Esempio n. 22
0
        // UI
        void OnGUI()
        {
            checkValidity();
            SketchfabPlugin.displayHeader();

            if (_currentUid.Length > 0)
            {
                displaySeparatedModelPage();
            }

            displaySearchOptions();
            displayNextPrev();
            _scrollView = GUILayout.BeginScrollView(_scrollView);
            displayResults();
            GUILayout.EndScrollView();
            if (_myModels && _logger.isUserLogged() && !_logger.canAccessOwnModels())
            {
                displayUpgradeToPro();
            }


            SketchfabPlugin.displayFooter();
        }
        private void checkValidity()
        {
            if (_browserManager == null)
            {
                _browserManager = new SketchfabBrowserManager(OnRefreshUpdate, true);
                resetFilters();
                _currentUid      = "";
                _categoryName    = "";
                _categoriesNames = new string[0];

                // Setup sortBy
                _sortBy    = new string[] { "Relevance", "Likes", "Views", "Recent" };
                _polyCount = new string[] { "Any", "Up to 10k", "10k to 50k", "50k to 100k", "100k to 250k", "250k +" };
                _searchIn  = new string[] { "free downloadable", "my models", "store purchases" };
                _license   = new string[] { "any", "CC BY", "CC BY SA", "CC BY-ND", "CC BY-NC", "CC BY-NC-SA", "CC BY-NC-ND", "CC0" };               // No search for store models so only CC licenses here
                this.Repaint();
                GL.sRGBWrite = true;
            }

            SketchfabPlugin.checkValidity();
            _ui     = SketchfabPlugin.getUI();
            _logger = SketchfabPlugin.getLogger();
        }
Esempio n. 24
0
 void OnEnable()
 {
     SketchfabPlugin.Initialize();
     checkValidity();
 }
        void displayFooter()
        {
            GUILayout.BeginVertical(GUILayout.Height(75));
            {
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    Color    old             = GUI.color;
                    GUIStyle whitebackground = new GUIStyle(GUI.skin.button);
                    whitebackground.richText = true;

                    GUILayout.Label("<b>Gain full API access</b> to your personal library of 3D models", SketchfabPlugin.getUI().getSketchfabBigLabel(), GUILayout.Height(48));
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Upgrade to PRO", GUILayout.Height(48), GUILayout.Width(225)))
                    {
                        Application.OpenURL(SketchfabPlugin.Urls.plans);
                    }
                    GUI.color = old;
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndVertical();
        }
Esempio n. 26
0
        void displayUpgradeToPro()
        {
            GUIStyle whiteBackground = new GUIStyle(GUI.skin.box);

            whiteBackground.normal.background = SketchfabUI.MakeTex(2, 2, Color.white);

            GUILayout.BeginVertical(whiteBackground, GUILayout.Height(75));
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("<b>Gain full API access</b> to your personal library of 3D models", SketchfabPlugin.getUI().getSketchfabBigLabel(), GUILayout.Height(48));
            GUILayout.FlexibleSpace();

            Color old = GUI.color;

            GUI.color = Color.white;
            GUIStyle whitebackground = new GUIStyle(GUI.skin.button);

            whitebackground.richText          = true;
            whitebackground.normal.background = SketchfabUI.MakeTex(2, 2, SketchfabUI.SKFB_BLUE);
            string buttonCaption = "<color=" + Color.white + "><b>Upgrade to PRO</b></color>";

            if (GUILayout.Button(buttonCaption, whitebackground, GUILayout.Height(48), GUILayout.Width(225)))
            {
                Application.OpenURL(SketchfabPlugin.Urls.plans);
            }
            GUI.color = old;

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
        }
Esempio n. 27
0
 private void Update()
 {
     SketchfabPlugin.Update();
 }
Esempio n. 28
0
 public void Update()
 {
     checkValidity();
     SketchfabPlugin.Update();
     _importer.Update();
 }
Esempio n. 29
0
 void OnEnable()
 {
     SketchfabPlugin.Initialize();
 }
 void OnEnable()
 {
     SketchfabPlugin.Initialize();
     _searchInIndex = SEARCH_IN.ALL_FREE_DOWNLOADABLE;
 }