Пример #1
0
        void AddOrUpdatePackage()
        {
            var target = _versionPopup.text != "(default)" ? _versionPopup.text : "";
            var id     = Utils.GetSpecificPackageId(_packageInfo.packageId, target);

            Client.Add(id);
        }
Пример #2
0
        public IEnumerator RequestCacheTest(LogType logType, string message, string url)
        {
            Assert.IsNotNull(Utils.GetRequestCache(url));

            LogAssert.Expect(logType, message);
            Utils.Request(url, x => Debug.Log("Success"));
            yield break;
        }
Пример #3
0
        /// <summary>
        /// Initializes UI.
        /// </summary>
        void InitializeUI()
        {
            if (_initialized)
            {
                return;
            }

            var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset> (TemplatePath);

            if (!asset)
            {
                return;
            }

#if UNITY_2019_1_OR_NEWER
            gitDetailActoins = asset.CloneTree().Q("detailActions");
            gitDetailActoins.styleSheets.Add(EditorGUIUtility.Load(StylePath) as StyleSheet);
#else
            _gitDetailActoins = asset.CloneTree(null).Q("detailActions");
            _gitDetailActoins.AddStyleSheetPath(StylePath);
#endif

            // Add callbacks
            _hostingIcon.clickable.clicked       += () => Application.OpenURL(Utils.GetRepoURL(_packageInfo));
            _viewDocumentation.clickable.clicked += () => Application.OpenURL(Utils.GetFileURL(_packageInfo, "README.md"));
            _viewChangelog.clickable.clicked     += () => Application.OpenURL(Utils.GetFileURL(_packageInfo, "CHANGELOG.md"));
            _viewLicense.clickable.clicked       += () => Application.OpenURL(Utils.GetFileURL(_packageInfo, "LICENSE.md"));

            // Move element to documentationContainer
            _detailControls         = parent.parent.Q("detailsControls");
            _documentationContainer = parent.parent.Q("documentationContainer");
            _originalDetailActions  = _documentationContainer.Q("detailActions");
            _documentationContainer.Add(_gitDetailActoins);

            _updateButton = new Button(AddOrUpdatePackage)
            {
                name = "update", text = "Up to date"
            };
            _updateButton.AddToClassList("action");
            _versionPopup = new Button(PopupVersions)
            {
                text = "hoge", style = { marginLeft = -4, marginRight = -3, marginTop = -3, marginBottom = -3, },
            };
            _versionPopup.AddToClassList("popup");
            _versionPopup.AddToClassList("popupField");
            _versionPopup.AddToClassList("versions");

            _detailControls.Q("updateCombo").Insert(1, _updateButton);
            _detailControls.Q("updateDropdownContainer").Add(_versionPopup);

            _initialized = true;
        }
Пример #4
0
        public IEnumerator RequestTest(LogType logType, string message, string url)
        {
            var path = Utils.GetRequestCachePath(url);

            Debug.Log(path);
            if (File.Exists(path))
            {
                File.Delete(path);
            }

            LogAssert.Expect(logType, message);
            yield return(Utils.Request(url, x => Debug.Log("Success")));
        }
Пример #5
0
        public bool ElementClassTest(string operations)
        {
            var _element = new VisualElement();

            if (0 < operations.Length)
            {
                foreach (bool flag in operations.Split(',').Select(System.Convert.ToBoolean))
                {
                    Utils.SetElementClass(_element, "test", flag);
                }
            }

            return(Utils.HasElementClass(_element, "test"));
        }
Пример #6
0
        public bool ElementVisibleTest(string operations)
        {
            var _element = new VisualElement();

            if (0 < operations.Length)
            {
                foreach (bool flag in operations.Split(',').Select(System.Convert.ToBoolean))
                {
                    Utils.SetElementDisplay(_element, flag);
                }
            }

            return(Utils.IsElementDisplay(_element));
        }
Пример #7
0
        /// <summary>
        /// Called by the Package Manager UI when the package selection changed.
        /// </summary>
        /// <param name="packageInfo">The newly selected package information (can be null)</param>
        public void OnPackageSelectionChange(PackageInfo packageInfo)
        {
            InitializeUI();
            if (!_initialized || packageInfo == null || _packageInfo == packageInfo)
            {
                return;
            }

            _packageInfo = packageInfo;

            var isGit = packageInfo.source == PackageSource.Git;

            Utils.SetElementDisplay(_gitDetailActoins, isGit);
            Utils.SetElementDisplay(_originalDetailActions, !isGit);
            Utils.SetElementDisplay(_detailControls.Q("", "popupField"), !isGit);
            Utils.SetElementDisplay(_updateButton, isGit);
            Utils.SetElementDisplay(_versionPopup, isGit);

            if (isGit)
            {
                Utils.RequestTags(_packageInfo.packageId, _tags);
                Utils.RequestBranches(_packageInfo.packageId, _branches);

                SetVersion(_packageInfo.version);
                EditorApplication.delayCall += () =>
                {
                    Utils.SetElementDisplay(_detailControls.Q("updateCombo"), true);
                    Utils.SetElementDisplay(_detailControls.Q("remove"), true);
                    _detailControls.Q("remove").SetEnabled(true);
                }
                ;
            }

            Utils.SetElementClass(_hostingIcon, "github", true);
            Utils.SetElementClass(_hostingIcon, "dark", EditorGUIUtility.isProSkin);
        }
Пример #8
0
 public string GetRepoIdTest(string packageId)
 {
     return(Utils.GetRepoId(packageId));
 }
Пример #9
0
 public string GetFileURLTest(bool isPackageInfoExist, string fileName)
 {
     return(Utils.GetFileURL(isPackageInfoExist ? pi : null, fileName));
 }
Пример #10
0
 public string GetRevisionHashTest(bool isPackageInfoExist)
 {
     return(Utils.GetRevisionHash(isPackageInfoExist ? pi : null));
 }
Пример #11
0
 public string GetRepoURLTest(bool isPackageInfoExist)
 {
     return(Utils.GetRepoURL(isPackageInfoExist ? pi : null));
 }