예제 #1
0
 void onClick_FindPackage()
 {
     root.SetEnabled(false);
     SetPhase(Phase.FindPackage);
     GitUtils.GetPackageJson(repoUrlText.value, versionSelectButton.text, packageName =>
     {
         root.SetEnabled(true);
         bool hasError            = string.IsNullOrEmpty(packageName);
         findPackageError.visible = hasError;
         if (!hasError)
         {
             EditorApplication.delayCall += () => packageNameLabel.text = packageName;
             SetPhase(Phase.InstallPackage);
         }
     });
 }
예제 #2
0
        void OnGUI()
        {
            EditorGUIUtility.labelWidth = 100;
            using (var ds = new EditorGUI.DisabledScope(PackageUtils.isBusy))
            {
                using (var ccs = new EditorGUI.ChangeCheckScope())
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUI.SetNextControlName("Repogitory URL");
                        _url = EditorGUILayout.TextField("Repogitory URL", _url);

                        if (!_focused)
                        {
                            EditorGUI.FocusTextInControl("Repogitory URL");
                            _focused = true;
                        }

                        if (ccs.changed)
                        {
                            _repoUrl   = PackageUtils.GetRepoUrl(_url);
                            _version   = "-- Select Version --";
                            _packageId = "";
                            GitUtils.GetRefs(_url, _refs, () => { EditorApplication.delayCall += Repaint; });
                        }

                        if (!PackageUtils.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(ver =>
                            {
                                _version   = _refs.Contains(ver) ? ver : "HEAD";
                                _packageId = "";
                                GitUtils.GetPackageJson(_url, _version, name =>
                                {
                                    _packageId = string.IsNullOrEmpty(name)
                                                                                ? null
                                                                                : name + "@" + _repoUrl + "#" + _version;
                                    EditorApplication.delayCall += Repaint;
                                });
                            });
                        }
                    }
                    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)))
                        {
                            PackageUtils.AddPackage(_packageId, req =>
                            {
                                if (req.Status == StatusCode.Success)
                                {
                                    Close();
                                }
                            });
                        }
                    }
                    if (_packageId == null)
                    {
                        GUILayout.Label(_errorBranch, GUILayout.Width(20));
                    }
                }
            }
        }