Пример #1
0
        public UpmVersionList(PackageInfo info, bool isInstalled, bool isUnityPackage)
        {
            m_LifecycleVersionString     = info.unityLifecycle?.version;
            m_LifecycleNextVersionString = info.unityLifecycle?.nextVersion;

            if (m_LifecycleVersionString != null)
            {
                SemVersionParser.TryParse(m_LifecycleVersionString, out m_LifecycleVersion);
            }
            if (m_LifecycleNextVersionString != null)
            {
                SemVersionParser.TryParse(m_LifecycleNextVersionString, out m_LifecycleNextVersion);
            }

            var mainVersion = new UpmPackageVersion(info, isInstalled, isUnityPackage);

            m_Versions = info.versions.compatible.Select(v =>
            {
                SemVersion?version;
                SemVersionParser.TryParse(v, out version);
                return(new UpmPackageVersion(info, false, version, mainVersion.displayName, isUnityPackage));
            }).ToList();

            AddToSortedVersions(m_Versions, mainVersion);

            m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled);
        }
Пример #2
0
 internal void UpdateVersion(UpmPackageVersion version)
 {
     for (var i = 0; i < m_Versions.Count; ++i)
     {
         if (m_Versions[i].uniqueId != version.uniqueId)
         {
             continue;
         }
         m_Versions[i] = version;
         return;
     }
 }
Пример #3
0
 // This function is only used to update the object, not to actually perform the add operation
 public void AddInstalledVersion(UpmPackageVersion newVersion)
 {
     if (m_InstalledIndex >= 0)
     {
         m_Versions[m_InstalledIndex].SetInstalled(false);
         if (m_Versions[m_InstalledIndex].installedFromPath)
         {
             m_Versions.RemoveAt(m_InstalledIndex);
         }
     }
     newVersion.SetInstalled(true);
     m_InstalledIndex = AddToSortedVersions(m_Versions, newVersion);
 }
Пример #4
0
        public static string[] FetchUrlsFromDescription(UpmPackageVersion version)
        {
            var           applicationProxy = ServicesContainer.instance.Resolve <ApplicationProxy>();
            List <string> urls             = new List <string>();

            var descriptionSlitWithUrl = version.packageInfo.description.Split(new[] { $"{k_BuiltinPackageDocsUrlKey}https://docs.unity3d.com/" }, StringSplitOptions.None);

            if (descriptionSlitWithUrl.Length > 1)
            {
                urls.Add($"https://docs.unity3d.com/{applicationProxy.shortUnityVersion}/Documentation/" + descriptionSlitWithUrl[1]);
            }

            var descriptionSlitWithoutUrl = version.packageInfo.description.Split(new[] { k_BuiltinPackageDocsUrlKey }, StringSplitOptions.None);

            if (descriptionSlitWithoutUrl.Length > 1)
            {
                urls.Add(descriptionSlitWithoutUrl[1]);
            }

            return(urls.ToArray());
        }
Пример #5
0
 private static int AddToSortedVersions(List <UpmPackageVersion> sortedVersions, UpmPackageVersion versionToAdd)
 {
     for (var i = 0; i < sortedVersions.Count; ++i)
     {
         if (versionToAdd.version != null && (sortedVersions[i].version?.CompareTo(versionToAdd.version) ?? -1) < 0)
         {
             continue;
         }
         // note that the difference between this and the previous function is that
         // two upm package versions could have the the same version but different package id
         if (sortedVersions[i].uniqueId == versionToAdd.uniqueId)
         {
             sortedVersions[i] = versionToAdd;
             return(i);
         }
         sortedVersions.Insert(i, versionToAdd);
         return(i);
     }
     sortedVersions.Add(versionToAdd);
     return(sortedVersions.Count - 1);
 }
Пример #6
0
 public static string FetchBuiltinDescription(UpmPackageVersion version)
 {
     return(string.IsNullOrEmpty(version?.packageInfo?.description) ?
            string.Format(L10n.Tr("This built in package controls the presence of the {0} module."), version.displayName) :
            version.packageInfo.description.Split(new[] { k_BuiltinPackageDocsUrlKey }, StringSplitOptions.None)[0]);
 }
Пример #7
0
 // This function is only used to update the object, not to actually perform the add operation
 public void AddInstalledVersion(UpmPackageVersion newVersion)
 {
     m_VersionList.AddInstalledVersion(newVersion);
     RefreshUnityType();
     LinkPackageAndVersions();
 }
Пример #8
0
 internal void UpdateVersion(UpmPackageVersion version)
 {
     m_VersionList.UpdateVersion(version);
     RefreshUnityType();
     LinkPackageAndVersions();
 }