Example #1
0
        public static string GetLicensesUrl(IOProxy IOProxy, IPackageVersion version, bool offline = false)
        {
            var upmVersion = version as UpmPackageVersion;

            if (upmVersion == null)
            {
                return(string.Empty);
            }

            if (offline)
            {
                return(GetOfflineLicensesUrl(IOProxy, upmVersion));
            }

            if (!string.IsNullOrEmpty(upmVersion.licensesUrl))
            {
                return(upmVersion.licensesUrl);
            }

            string url;

            if (!string.IsNullOrEmpty(GetPackageUrlRedirect(upmVersion)))
            {
                url = "https://unity3d.com/legal/licenses/Unity_Companion_License";
            }
            else
            {
                url = $"http://docs.unity3d.com/Packages/{upmVersion.shortVersionId}/license/index.html";
            }
            return(url);
        }
Example #2
0
        public UpmVersionList(IOProxy ioProxy, IEnumerable <UpmPackageVersion> versions = null)
        {
            ResolveDependencies(ioProxy);

            m_Versions       = versions?.ToList() ?? new List <UpmPackageVersion>();
            m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled);
        }
Example #3
0
        public static string GetDocumentationUrl(IOProxy IOProxy, IPackageVersion version, bool offline = false)
        {
            var upmVersion = version as UpmPackageVersion;

            if (upmVersion == null)
            {
                return(string.Empty);
            }

            if (offline)
            {
                return(GetOfflineDocumentationUrl(IOProxy, upmVersion));
            }

            if (!string.IsNullOrEmpty(upmVersion.documentationUrl))
            {
                return(upmVersion.documentationUrl);
            }

            if (upmVersion.HasTag(PackageTag.BuiltIn) && !string.IsNullOrEmpty(upmVersion.description))
            {
                var split = SplitBuiltinDescription(upmVersion);
                if (split.Length > 1)
                {
                    return(split[1]);
                }
            }
            return($"http://docs.unity3d.com/Packages/{upmVersion.shortVersionId}/index.html");
        }
Example #4
0
 public void ResolveDependencies(PackageManagerPrefs packageManagerPrefs,
                                 UpmCache upmCache,
                                 IOProxy IOProxy)
 {
     m_PackageManagerPrefs = packageManagerPrefs;
     m_UpmCache            = upmCache;
     m_IOProxy             = IOProxy;
 }
Example #5
0
 private static string GetOfflineLicensesUrl(IOProxy IOProxy, UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var licenseFile = Path.Combine(version.packageInfo.resolvedPath, "LICENSE.md");
         return(IOProxy.FileExists(licenseFile) ? new Uri(licenseFile).AbsoluteUri : string.Empty);
     }
     return(string.Empty);
 }
Example #6
0
 internal Sample(IOProxy ioProxy, string displayName, string description, string resolvedPath, string importPath, bool interactiveImport)
 {
     this.displayName       = displayName;
     this.description       = description;
     this.resolvedPath      = resolvedPath;
     this.importPath        = importPath;
     this.interactiveImport = interactiveImport;
     this.m_IOProxy         = ioProxy;
 }
Example #7
0
 private static string GetOfflineChangelogUrl(IOProxy IOProxy, UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var changelogFile = Path.Combine(version.packageInfo.resolvedPath, "CHANGELOG.md");
         return(IOProxy.FileExists(changelogFile) ? new Uri(changelogFile).AbsoluteUri : string.Empty);
     }
     return(string.Empty);
 }
        public void ResolveDependencies(ApplicationProxy application, AssetStoreUtils assetStoreUtils, IOProxy systemIOProxy)
        {
            m_Application = application;
            m_IOProxy     = systemIOProxy;

            foreach (var productInfo in m_ProductInfos.Values)
            {
                productInfo.ResolveDependencies(assetStoreUtils);
            }
        }
Example #9
0
 internal Sample(IOProxy ioProxy, AssetDatabaseProxy assetDatabase, string displayName, string description, string resolvedPath, string importPath, bool interactiveImport)
 {
     m_IOProxy              = ioProxy;
     m_AssetDatabase        = assetDatabase;
     this.displayName       = displayName;
     this.description       = description;
     this.resolvedPath      = resolvedPath;
     this.importPath        = importPath;
     this.interactiveImport = interactiveImport;
 }
Example #10
0
 public void ResolveDependencies(PackageManagerPrefs packageManagerPrefs,
                                 UpmCache upmCache,
                                 IOProxy IOProxy,
                                 PackageManagerProjectSettingsProxy settingsProxy)
 {
     m_PackageManagerPrefs = packageManagerPrefs;
     m_UpmCache            = upmCache;
     m_IOProxy             = IOProxy;
     m_SettingsProxy       = settingsProxy;
 }
Example #11
0
        public UpmPackage(IOProxy ioProxy, PackageInfo info, bool isInstalled, bool isDiscoverable)
        {
            ResolveDependencies(ioProxy);

            m_Progress       = PackageProgress.None;
            m_Name           = info.name;
            m_Errors         = new List <UIError>();
            m_IsDiscoverable = isDiscoverable;
            m_VersionList    = new UpmVersionList(ioProxy, info, isInstalled);
            m_Type           = versions.primary.HasTag(PackageTag.BuiltIn) ? PackageType.BuiltIn : PackageType.Installable;
        }
Example #12
0
        public UpmPackage(IOProxy ioProxy, string name, bool isDiscoverable, PackageType type = PackageType.None)
        {
            ResolveDependencies(ioProxy);

            m_Progress       = PackageProgress.None;
            m_Name           = name;
            m_IsDiscoverable = isDiscoverable;
            m_VersionList    = new UpmVersionList(ioProxy);
            m_Errors         = new List <UIError>();
            m_Type           = type;
        }
Example #13
0
 public void ResolveDependencies(IOProxy ioProxy)
 {
     if (m_Versions == null)
     {
         return;
     }
     foreach (var version in m_Versions)
     {
         version.ResolveDependencies(ioProxy);
     }
 }
 public void ResolveDependencies(AssetStoreUtils assetStoreUtils, IOProxy ioProxy)
 {
     if (m_Versions == null)
     {
         return;
     }
     foreach (var version in m_Versions)
     {
         version.ResolveDependencies(assetStoreUtils, ioProxy);
     }
 }
        public UpmPackageVersion(IOProxy ioProxy, PackageInfo packageInfo, bool isInstalled, SemVersion?version, string displayName)
        {
            ResolveDependencies(ioProxy);

            m_Version         = version;
            m_VersionString   = m_Version?.ToString();
            m_DisplayName     = displayName;
            m_IsInstalled     = isInstalled;
            m_PackageUniqueId = packageInfo.name;

            UpdatePackageInfo(packageInfo);
        }
        public UpmPackageVersion(IOProxy ioProxy, PackageInfo packageInfo, bool isInstalled)
        {
            ResolveDependencies(ioProxy);

            SemVersionParser.TryParse(packageInfo.version, out m_Version);
            m_VersionString   = m_Version?.ToString();
            m_DisplayName     = packageInfo.displayName;
            m_IsInstalled     = isInstalled;
            m_PackageUniqueId = packageInfo.name;

            UpdatePackageInfo(packageInfo);
        }
        public void ResolveDependencies(UnityConnectProxy unityConnect,
                                        AssetStoreCache assetStoreCache,
                                        AssetStoreUtils assetStoreUtils,
                                        AssetStoreRestAPI assetStoreRestAPI,
                                        UpmClient upmClient,
                                        IOProxy ioProxy)
        {
            m_UnityConnect      = unityConnect;
            m_AssetStoreCache   = assetStoreCache;
            m_AssetStoreUtils   = assetStoreUtils;
            m_AssetStoreRestAPI = assetStoreRestAPI;
            m_UpmClient         = upmClient;
            m_IOProxy           = ioProxy;

            m_ListOperation?.ResolveDependencies(unityConnect, assetStoreRestAPI);
        }
Example #18
0
        public UpmVersionList(IOProxy ioProxy, PackageInfo info, bool isInstalled)
        {
            ResolveDependencies(ioProxy);

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

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

            AddToSortedVersions(m_Versions, mainVersion);

            m_InstalledIndex = m_Versions.FindIndex(v => v.isInstalled);
        }
Example #19
0
        public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, AssetStorePurchaseInfo purchaseInfo, AssetStoreProductInfo productInfo, UpmPackage package)
        {
            ResolveDependencies(assetStoreUtils, ioProxy);

            m_Errors    = new List <UIError>();
            m_Progress  = PackageProgress.None;
            m_Type      = PackageType.AssetStore;
            m_Name      = package?.name ?? string.Empty;
            m_ProductId = productInfo?.id.ToString();

            m_Images      = productInfo?.images ?? new List <PackageImage>();
            m_Links       = productInfo?.links ?? new List <PackageLink>();
            m_VersionList = new AssetStoreVersionList(assetStoreUtils, ioProxy);

            m_Labels             = purchaseInfo?.tags;
            m_PurchasedTimeTicks = !string.IsNullOrEmpty(purchaseInfo?.purchasedTime) ? DateTime.Parse(purchaseInfo?.purchasedTime).Ticks : 0;

            m_UpmVersionList = package?.versions as UpmVersionList ?? new UpmVersionList(ioProxy);
            if (productInfo != null)
            {
                foreach (var version in m_UpmVersionList.Cast <UpmPackageVersion>())
                {
                    version.UpdateProductInfo(productInfo);
                }
            }

            m_AssetStoreLink = productInfo?.assetStoreLink.url;

            var firstPublishedDateString = productInfo?.firstPublishedDate ?? string.Empty;

            m_FirstPublishedDateTicks = !string.IsNullOrEmpty(firstPublishedDateString) ? DateTime.Parse(firstPublishedDateString).Ticks : 0;

            if (purchaseInfo == null)
            {
                var errorMessage = L10n.Tr("Unable to get purchase details because you may not have purchased this package.");
                AddError(new UIError(UIErrorCode.AssetStorePackageError, errorMessage));
            }
            if (string.IsNullOrEmpty(productInfo?.id) || string.IsNullOrEmpty(productInfo?.versionId))
            {
                AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid product details.")));
            }
            else if (string.IsNullOrEmpty(package?.name))
            {
                AddError(new UIError(UIErrorCode.AssetStorePackageError, L10n.Tr("Invalid package info.")));
            }
        }
        public void ResolveDependencies(UnityConnectProxy unityConnect,
                                        AssetDatabaseProxy assetDatabase,
                                        AssetStoreUtils assetStoreUtils,
                                        AssetStoreClient assetStoreClient,
                                        AssetStoreDownloadManager assetStoreDownloadManager,
                                        UpmClient upmClient,
                                        IOProxy ioProxy)
        {
            m_UnityConnect              = unityConnect;
            m_AssetDatabase             = assetDatabase;
            m_AssetStoreClient          = assetStoreClient;
            m_AssetStoreDownloadManager = assetStoreDownloadManager;
            m_UpmClient = upmClient;
            m_IOProxy   = ioProxy;

            foreach (var package in m_SerializedAssetStorePackages)
            {
                package.ResolveDependencies(assetStoreUtils, ioProxy);
            }
        }
Example #21
0
        public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, string productId, UIError error)
        {
            ResolveDependencies(assetStoreUtils, ioProxy);

            m_Errors = new List <UIError> {
                error
            };
            m_Progress  = PackageProgress.None;
            m_Type      = PackageType.AssetStore;
            m_Name      = string.Empty;
            m_ProductId = productId;

            m_Images         = new List <PackageImage>();
            m_Links          = new List <PackageLink>();
            m_VersionList    = new AssetStoreVersionList(assetStoreUtils, ioProxy);
            m_UpmVersionList = new UpmVersionList(ioProxy);

            m_Labels             = new List <string>();
            m_PurchasedTimeTicks = 0;
        }
        private static List <Sample> GetSamplesFromPackageInfo(IOProxy ioProxy, PackageInfo packageInfo)
        {
            if (string.IsNullOrEmpty(packageInfo?.resolvedPath))
            {
                return(null);
            }

            var jsonPath = Path.Combine(packageInfo.resolvedPath, "package.json");

            if (!ioProxy.FileExists(jsonPath))
            {
                return(null);
            }

            try
            {
                var packageJson = Json.Deserialize(ioProxy.FileReadAllText(jsonPath)) as Dictionary <string, object>;
                var samples     = packageJson.GetList <IDictionary <string, object> >("samples");
                return(samples?.Select(sample =>
                {
                    var displayName = sample.GetString("displayName");
                    var path = sample.GetString("path");
                    var description = sample.GetString("description");
                    var interactiveImport = sample.Get("interactiveImport", false);

                    var resolvedSamplePath = Path.Combine(packageInfo.resolvedPath, path);
                    var importPath = IOUtils.CombinePaths(
                        Application.dataPath,
                        "Samples",
                        IOUtils.SanitizeFileName(packageInfo.displayName),
                        packageInfo.version,
                        IOUtils.SanitizeFileName(displayName)
                        );
                    return new Sample(ioProxy, displayName, description, resolvedSamplePath, importPath, interactiveImport);
                }).ToList());
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #23
0
        public static string GetChangelogUrl(IOProxy IOProxy, IPackageVersion version, bool offline = false)
        {
            var upmVersion = version as UpmPackageVersion;

            if (upmVersion == null)
            {
                return(string.Empty);
            }

            if (offline)
            {
                return(GetOfflineChangelogUrl(IOProxy, upmVersion));
            }

            if (!string.IsNullOrEmpty(upmVersion.changelogUrl))
            {
                return(upmVersion.changelogUrl);
            }

            return($"http://docs.unity3d.com/Packages/{upmVersion.shortVersionId}/changelog/CHANGELOG.html");
        }
Example #24
0
 private static string GetOfflineDocumentationUrl(IOProxy IOProxy, UpmPackageVersion version)
 {
     if (version?.isAvailableOnDisk ?? false)
     {
         var docsFolder = Path.Combine(version.packageInfo.resolvedPath, "Documentation~");
         if (!IOProxy.DirectoryExists(docsFolder))
         {
             docsFolder = Path.Combine(version.packageInfo.resolvedPath, "Documentation");
         }
         if (IOProxy.DirectoryExists(docsFolder))
         {
             var mdFiles = IOProxy.DirectoryGetFiles(docsFolder, "*.md", SearchOption.TopDirectoryOnly);
             var docsMd  = mdFiles.FirstOrDefault(d => Path.GetFileName(d).ToLower() == "index.md")
                           ?? mdFiles.FirstOrDefault(d => Path.GetFileName(d).ToLower() == "tableofcontents.md") ?? mdFiles.FirstOrDefault();
             if (!string.IsNullOrEmpty(docsMd))
             {
                 return(new Uri(docsMd).AbsoluteUri);
             }
         }
     }
     return(string.Empty);
 }
Example #25
0
        public ServicesContainer()
        {
            // In the constructor we only need to worry about creating a brand new instance.
            // In the case of assembly reload, a deserialize step will automatically happen after the constructor
            // to restore all the serializable states/services and we don't need to worry about that
            m_HttpClientFactory  = new HttpClientFactory();
            m_UnityOAuthProxy    = new UnityOAuthProxy();
            m_SelectionProxy     = new SelectionProxy();
            m_AssetDatabaseProxy = new AssetDatabaseProxy();
            m_UnityConnectProxy  = new UnityConnectProxy();
            m_ApplicationProxy   = new ApplicationProxy();
            m_IOProxy            = new IOProxy();
            m_SettingsProxy      = new PackageManagerProjectSettingsProxy();

            m_ResourceLoader = new ResourceLoader();

            m_AssetStoreCache           = new AssetStoreCache();
            m_AssetStoreClient          = new AssetStoreClient();
            m_AssetStoreOAuth           = new AssetStoreOAuth();
            m_AssetStoreUtils           = new AssetStoreUtils();
            m_AssetStoreRestAPI         = new AssetStoreRestAPI();
            m_AssetStoreDownloadManager = new AssetStoreDownloadManager();

            m_UpmCache  = new UpmCache();
            m_UpmClient = new UpmClient();

            m_PackageFiltering    = new PackageFiltering();
            m_PackageManagerPrefs = new PackageManagerPrefs();

            m_PackageDatabase = new PackageDatabase();
            m_PageManager     = new PageManager();

            // Since dictionaries doesn't survive through serialization, we always re-create the default registration
            m_RegisteredObjects = new Dictionary <Type, object>();
            RegisterDefaultServices();

            m_DependenciesResolved = false;
        }
Example #26
0
 public void ResolveDependencies(AssetStoreUtils assetStoreUtils, IOProxy ioProxy)
 {
     m_VersionList?.ResolveDependencies(assetStoreUtils, ioProxy);
     m_UpmVersionList?.ResolveDependencies(ioProxy);
 }
Example #27
0
 public void ResolveDependencies(IOProxy ioProxy)
 {
     m_IOProxy = ioProxy;
     m_VersionList?.ResolveDependencies(ioProxy);
 }
 public void ResolveDependencies(IOProxy ioProxy)
 {
     m_IOProxy = ioProxy;
 }
Example #29
0
 internal void ResolveDependencies(IOProxy ioProxy)
 {
     m_IOProxy = ioProxy;
 }
        internal static IEnumerable <Sample> FindByPackage(PackageInfo package, UpmCache upmCache, IOProxy ioProxy, AssetDatabaseProxy assetDatabaseProxy)
        {
            if (string.IsNullOrEmpty(package?.upmReserved) && string.IsNullOrEmpty(package.resolvedPath))
            {
                return(Enumerable.Empty <Sample>());
            }

            try
            {
                IEnumerable <IDictionary <string, object> > samples = null;
                var upmReserved = upmCache.ParseUpmReserved(package);
                if (upmReserved != null)
                {
                    samples = upmReserved.GetList <IDictionary <string, object> >("samples");
                }

                if (samples == null)
                {
                    var jsonPath = ioProxy.PathsCombine(package.resolvedPath, "package.json");
                    if (ioProxy.FileExists(jsonPath))
                    {
                        var packageJson = Json.Deserialize(ioProxy.FileReadAllText(jsonPath)) as Dictionary <string, object>;
                        samples = packageJson.GetList <IDictionary <string, object> >("samples");
                    }
                }

                return(samples?.Select(sample =>
                {
                    var displayName = sample.GetString("displayName");
                    var path = sample.GetString("path");
                    var description = sample.GetString("description");
                    var interactiveImport = sample.Get("interactiveImport", false);

                    var resolvedSamplePath = ioProxy.PathsCombine(package.resolvedPath, path);
                    var importPath = ioProxy.PathsCombine(
                        Application.dataPath,
                        "Samples",
                        IOUtils.SanitizeFileName(package.displayName),
                        package.version,
                        string.IsNullOrEmpty(displayName) ? string.Empty : IOUtils.SanitizeFileName(displayName)
                        );
                    return new Sample(ioProxy, assetDatabaseProxy, displayName, description, resolvedSamplePath, importPath, interactiveImport);
                }).ToArray() ?? Enumerable.Empty <Sample>());
            }
            catch (IOException e)
            {
                Debug.Log($"[Package Manager Window] Cannot find samples for package {package.displayName}: {e}");
                return(Enumerable.Empty <Sample>());
            }
            catch (InvalidCastException e)
            {
                Debug.Log($"[Package Manager Window] Invalid sample data for package {package.displayName}: {e}");
                return(Enumerable.Empty <Sample>());
            }
            catch (Exception)
            {
                return(Enumerable.Empty <Sample>());
            }
        }