Exemple #1
0
        private void AddOrUpdatePackage()
        {
            var target = _versionPopup.text != "(default)" ? _versionPopup.text : "";
            var id     = UnityPackageUtilities.GetSpecificPackageId(_packageInfo.packageId, target);

            UnityPackageUtilities.AddPackage(id);

            _versionPopup.SetEnabled(false);
            _updateButton.SetEnabled(false);
            _updateButton.text = "Updating to";
        }
Exemple #2
0
        private void OnGUI()
        {
            EditorGUIUtility.labelWidth = 100;

            if (_focused &&
                (Event.current.keyCode == KeyCode.Return ||
                 Event.current.keyCode == KeyCode.Tab))
            {
                _ready   = true;
                _focused = false;
                GUI.FocusControl(null);
            }

            using (new EditorGUI.DisabledScope(UnityPackageUtilities.IsBusy))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    GUI.SetNextControlName("Repository URL");
                    _url     = EditorGUILayout.TextField("Repository URL", _url);
                    _focused = GUI.GetNameOfFocusedControl().Equals("Repository URL");

                    if (_ready)
                    {
                        _ready     = false;
                        _repoUrl   = UnityPackageUtilities.GetRepoUrl(_url);
                        _version   = "-- Select Version --";
                        _packageId = string.Empty;
                        GitUtilities.GetRefs(_url, _refs, null);
                    }

                    if (!UnityPackageUtilities.IsBusy && !string.IsNullOrEmpty(_url) && _refs.Count == 0)
                    {
                        GUILayout.Label(_errorUrl, GUILayout.Width(20));
                    }
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Version");

                    using (new EditorGUI.DisabledScope(_refs.Count == 0))
                    {
                        if (GUILayout.Button(_version, EditorStyles.popup))
                        {
                            PopupVersions(OnVersionChanged);
                        }
                    }

                    using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(_packageId)))
                    {
                        if (GUILayout.Button(new GUIContent("Add", $"Add a package '{_packageId}' to the project."), EditorStyles.miniButton, GUILayout.Width(60)))
                        {
                            UnityPackageUtilities.AddPackage(_packageId, CheckStatus);
                        }
                    }

                    if (_packageId == null)
                    {
                        GUILayout.Label(_errorBranch, GUILayout.Width(20));
                    }
                }
            }
        }