Ejemplo n.º 1
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();
        }
        // GUI functions
        public static void displayHeader()
        {
            GUIStyle whiteGround = new GUIStyle(GUI.skin.box);

            whiteGround.normal.background = SketchfabUI.MakeTex(2, 2, new Color(1f, 1f, 1f, 1f));

            GUILayout.BeginHorizontal(whiteGround, GUILayout.Height(75));
            _logger.showLoginUi();
            GUILayout.FlexibleSpace();

            // If banner available, display it
            if (bannerTexture != null)
            {
                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(bannerTexture, _ui.getSketchfabLabel()))
                {
                    Application.OpenURL(Urls.storeUrl);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
            }

            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            GUILayout.Label(Resources.Load("SketchfabGrey") as Texture2D, GUILayout.Height(40), GUILayout.Width(190));
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 3
0
 // Logger needs API to check login
 // so initialize API before Logger
 public static void Initialize()
 {
     _ui     = new SketchfabUI();
     _api    = new SketchfabAPI();
     _logger = new SketchfabLogger();
     checkUpdates();
     DEFAULT_AVATAR = Resources.Load("defaultAvatar") as Texture2D;
 }
        // Must be called in OnGUI function in order to have EditorStyle classes created
        public static SketchfabUI getUI()
        {
            if (_ui == null)
            {
                _ui = new SketchfabUI();
            }

            return(_ui);
        }
Ejemplo n.º 5
0
        private void showPrivate()
        {
            if (!_logger.canPrivate())
            {
                if (_logger.isUserBasic())
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    GUIContent content = new GUIContent(" features", SketchfabUI.getPlanIcon("pro"));
                    GUILayout.Label(content, EditorStyles.boldLabel, GUILayout.Height(12));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Upgrade your account", GUILayout.Height(18)))
                    {
                        Application.OpenURL(SketchfabPlugin.Urls.plans);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
                else
                {
                    if (GUILayout.Button("(You cannot set any other model to private (limit reached))", _ui.getSketchfabClickableLabel(), GUILayout.Height(20)))
                    {
                        Application.OpenURL(SketchfabPlugin.Urls.plans);
                    }
                }
            }
            else
            {
                GUILayout.Label("Set the model to Private", EditorStyles.centeredGreyMiniLabel);
            }

            GUI.enabled = _logger.canPrivate();
            EditorGUILayout.BeginVertical("Box");
            GUILayout.BeginHorizontal();
            param_private = EditorGUILayout.Toggle("Private model", param_private);

            if (GUILayout.Button("more info", _ui.getSketchfabClickableLabel(), GUILayout.Height(20)))
            {
                Application.OpenURL(SketchfabPlugin.Urls.privateInfo);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUI.enabled = param_private;
            GUILayout.Label("Password");
            param_password = EditorGUILayout.TextField(param_password);
            EditorGUILayout.EndVertical();

            GUI.enabled = true;
        }
Ejemplo n.º 6
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();
 }
Ejemplo n.º 7
0
 private void checkValidity()
 {
     SketchfabPlugin.checkValidity();
     if (_ui == null)
     {
         _ui = new SketchfabUI();
     }
     if (_importer == null)
     {
         Initialize();
     }
 }
Ejemplo n.º 8
0
        public SketchfabProfile(string usrName, string usr, string planLb)
        {
            username = usrName;
            // Format display name
            string limitedDisplayName = usr;

            if (usr.Length > MAX_DISPLAY_NAME_LENGTH)
            {
                limitedDisplayName = usr.Substring(0, MAX_DISPLAY_NAME_LENGTH) + "...";
            }
            displayName = limitedDisplayName;

            switch (planLb)
            {
            case "plus":
                maxUploadSize = 100 * 1024 * 1024;
                accountLabel  = "PLUS";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "pro":
                maxUploadSize = 200 * 1024 * 1024;
                accountLabel  = "PRO";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "prem":
                maxUploadSize = 500 * 1024 * 1024;
                accountLabel  = "PREMIUM";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "biz":
                maxUploadSize = 500 * 1024 * 1024;
                accountLabel  = "BUSINESS";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "ent":
                maxUploadSize = 500 * 1024 * 1024;
                accountLabel  = "ENTERPRISE";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            default:
                maxUploadSize = 50 * 1024 * 1024;
                accountLabel  = "BASIC";
                break;
            }
        }
Ejemplo n.º 9
0
 private void checkValidity()
 {
     if (_ui == null)
     {
         _ui = SketchfabPlugin.getUI();
     }
     if (_api == null)
     {
         _api = SketchfabPlugin.getAPI();
     }
     if (_logger == null)
     {
         _logger = SketchfabPlugin.getLogger();
     }
 }
Ejemplo n.º 10
0
        // GUI functions
        public static void displayHeader()
        {
            GUIStyle whiteGround = new GUIStyle(GUI.skin.box);

            whiteGround.normal.background = SketchfabUI.MakeTex(2, 2, new Color(1f, 1f, 1f, 1f));

            GUILayout.BeginHorizontal(whiteGround, GUILayout.Height(75));
            _logger.showLoginUi();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            GUILayout.Label(Resources.Load("SketchfabGrey") as Texture2D, GUILayout.Height(40), GUILayout.Width(190));
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
        public static void onVersionCheckSuccess(string response)
        {
            JSONNode node = Utils.JSONParse(response);

            if (node != null && node[0]["tag_name"] != null)
            {
                string fetchedVersion = node[0]["tag_name"];
                if (fetchedVersion == VERSION)
                {
                    versionCaption = "(up to date)";
                }
                else
                {
                    versionCaption = SketchfabUI.ErrorTextColor("(out of date)");
                }
            }
        }
Ejemplo n.º 12
0
        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;
        }
Ejemplo n.º 13
0
        private void showPrivate()
        {
            if (!_logger.canPrivate())
            {
                if (_logger.isUserBasic())
                {
                    if (GUILayout.Button("(" + SketchfabUI.ClickableTextColor("Upgrade to a paid account to set your model to private") + ")", _ui.SkfbClickableLabel, GUILayout.Height(20)))
                    {
                        Application.OpenURL(SketchfabPlugin.Urls.plans);
                    }
                }
                else
                {
                    if (GUILayout.Button("(" + SketchfabUI.ClickableTextColor("You cannot set any other model to private (limit reached)") + ")", _ui.SkfbClickableLabel, GUILayout.Height(20)))
                    {
                        Application.OpenURL(SketchfabPlugin.Urls.plans);
                    }
                }
            }
            else
            {
                GUILayout.Label("Set the model to Private", EditorStyles.centeredGreyMiniLabel);
            }

            GUI.enabled = _logger.canPrivate();
            EditorGUILayout.BeginVertical("Box");
            GUILayout.BeginHorizontal();
            param_private = EditorGUILayout.Toggle("Private model", param_private);

            if (GUILayout.Button("( " + SketchfabUI.ClickableTextColor("more info") + ")", _ui.SkfbClickableLabel, GUILayout.Height(20)))
            {
                Application.OpenURL(SketchfabPlugin.Urls.privateInfo);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUI.enabled = param_private;
            GUILayout.Label("Password");
            param_password = EditorGUILayout.TextField(param_password);
            EditorGUILayout.EndVertical();

            GUI.enabled = true;
        }
Ejemplo n.º 14
0
        private void showOptions()
        {
            GUILayout.Label("Options", EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();
            opt_exportAnimation = EditorGUILayout.Toggle("Export animation (beta)", opt_exportAnimation);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            opt_exportSelection = EditorGUILayout.Toggle("Export selection", opt_exportSelection);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            param_autopublish = EditorGUILayout.Toggle("Publish immediately ", param_autopublish);
            if (GUILayout.Button("(" + SketchfabUI.ClickableTextColor("more info") + ")", _ui.SkfbClickableLabel, GUILayout.Height(20)))
            {
                Application.OpenURL(SketchfabPlugin.Urls.latestRelease);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 15
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();
        }
        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();
        }
Ejemplo n.º 17
0
        public SketchfabProfile(string usrName, string usr, string planLb)
        {
            username    = usrName;
            displayName = usr;

            switch (planLb)
            {
            case "pro":
                maxUploadSize = 200 * 1024 * 1024;
                accountLabel  = "PRO";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "prem":
                maxUploadSize = 500 * 1024 * 1024;
                accountLabel  = "PREMIUM";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "biz":
                maxUploadSize = 500 * 1024 * 1024;
                accountLabel  = "BUSINESS";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            case "ent":
                maxUploadSize = 500 * 1024 * 1024;
                accountLabel  = "ENTERPRISE";
                planIcon      = SketchfabUI.getPlanIcon(planLb);
                break;

            default:
                maxUploadSize = 50 * 1024 * 1024;
                accountLabel  = "BASIC";
                break;
            }
        }
Ejemplo n.º 18
0
        private void OnGUI()
        {
            if (_currentModel != null && show)
            {
                _scrollView = GUILayout.BeginScrollView(_scrollView);
                SketchfabModel model = _currentModel;

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical();
                _ui.displayModelName(model.name);
                _ui.displayContent("by " + model.author);
                GUILayout.EndVertical();

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("View on Sketchfab"))
                {
                    Application.OpenURL(SketchfabPlugin.Urls.modelUrl + "/" + _currentModel.uid);
                }

                GUILayout.EndHorizontal();


                GUIStyle blackGround = new GUIStyle(GUI.skin.box);
                blackGround.normal.background = SketchfabUI.MakeTex(2, 2, new Color(0f, 0f, 0f, 1f));

                GUILayout.BeginHorizontal(blackGround);
                GUILayout.FlexibleSpace();
                if (PlayerSettings.colorSpace == ColorSpace.Linear)
                {
                    bool backup = GL.sRGBWrite;
                    GL.sRGBWrite = true;
                    GUILayout.Label(model._preview);
                    GL.sRGBWrite = backup;
                }
                else
                {
                    GUILayout.Label(model._preview);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                displayImportSettings();
                GUILayout.Label("");

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical(GUILayout.Width(250));
                _ui.displayTitle("MODEL INFORMATION");
                _ui.displayModelStats("Vertex count", " " + Utils.humanifySize(model.vertexCount));
                _ui.displayModelStats("Face count", " " + Utils.humanifySize(model.faceCount));
                if (model.hasAnimation != "")
                {
                    _ui.displayModelStats("Animation", model.hasAnimation);
                }

                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(300));
                _ui.displayTitle("LICENSE");
                if (model.licenseJson != null)
                {
                    _ui.displayContent(model.licenseJson["fullName"]);
                    _ui.displaySubContent(model.licenseJson["requirements"]);
                }
                else
                {
                    _ui.displaySubContent("Fetching license data");
                }
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
            }
        }
Ejemplo n.º 19
0
        private void OnGUI()
        {
            if (_currentModel != null && show)
            {
                _scrollView = GUILayout.BeginScrollView(_scrollView);
                SketchfabModel model = _currentModel;

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical();
                _ui.displayModelName(model.name);
                _ui.displayContent("by " + model.author);
                GUILayout.BeginHorizontal();
                GUIContent viewSkfb = new GUIContent("View on Sketchfab", _ui.SKETCHFAB_ICON);
                if (GUILayout.Button(viewSkfb, GUILayout.Height(24), GUILayout.Width(140)))
                {
                    Application.OpenURL(SketchfabPlugin.Urls.modelUrl + "/" + _currentModel.uid);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();


                GUIStyle blackGround = new GUIStyle(GUI.skin.box);
                blackGround.normal.background = SketchfabUI.MakeTex(2, 2, new Color(0f, 0f, 0f, 1f));

                GUILayout.BeginHorizontal(blackGround);
                GUILayout.FlexibleSpace();

                GUILayout.Label(model._preview);

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

                displayImportSettings();
                GUILayout.Label("");

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical(GUILayout.Width(250));
                _ui.displayTitle("MODEL INFORMATION");
                _ui.displayModelStats("Vertex count", " " + Utils.humanifySize(model.vertexCount));
                _ui.displayModelStats("Face count", " " + Utils.humanifySize(model.faceCount));
                if (model.hasAnimation != "")
                {
                    _ui.displayModelStats("Animation", model.hasAnimation);
                }

                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(300));
                _ui.displayTitle("LICENSE");
                if (model.licenseJson != null && model.licenseJson["fullName"] != null)
                {
                    _ui.displayContent(model.licenseJson["fullName"]);
                    _ui.displaySubContent(model.licenseJson["requirements"]);
                }
                else if (model.vertexCount != 0)
                {
                    _ui.displayContent("Personal");
                    _ui.displaySubContent("You own this model");
                }
                else
                {
                    _ui.displaySubContent("Fetching license data");
                }
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUILayout.EndScrollView();
            }
        }
Ejemplo n.º 20
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();
        }