public virtual Texture2D LoadImage(long productId, string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }

            var hash = Hash128.Compute(url);

            try
            {
                var path = m_IOProxy.PathsCombine(m_Application.userAppDataPath, "Asset Store", "Cache", "Images", productId.ToString(), hash.ToString());
                if (m_IOProxy.FileExists(path))
                {
                    var texture = new Texture2D(2, 2);
                    if (texture.LoadImage(m_IOProxy.FileReadAllBytes(path)))
                    {
                        return(texture);
                    }
                }
            }
            catch (System.IO.IOException e)
            {
                Debug.Log($"[Package Manager] Cannot load image: {e.Message}");
            }

            return(null);
        }
Exemple #2
0
 public void SetLocalPath(string path)
 {
     m_LocalPath = path ?? string.Empty;
     try
     {
         m_IsAvailableOnDisk = !string.IsNullOrEmpty(m_LocalPath) && m_IOProxy.FileExists(m_LocalPath);
     }
     catch (System.IO.IOException e)
     {
         Debug.Log($"[Package Manager Window] Cannot determine local path for {packageUniqueId}: {e.Message}");
         m_IsAvailableOnDisk = false;
     }
 }
Exemple #3
0
 public static string GetOfflineLicenses(IOProxy IOProxy, IPackageVersion version)
 {
     if (version?.isAvailableOnDisk == true && version.packageInfo != null)
     {
         try
         {
             var licenseFile = IOProxy.PathsCombine(version.packageInfo.resolvedPath, "LICENSE.md");
             return(IOProxy.FileExists(licenseFile) ? licenseFile : string.Empty);
         }
         catch (System.IO.IOException) {}
     }
     return(string.Empty);
 }
Exemple #4
0
 public static string GetOfflineChangelog(IOProxy IOProxy, IPackageVersion version)
 {
     if (version?.isAvailableOnDisk == true && version.packageInfo != null)
     {
         try
         {
             var changelogFile = IOProxy.PathsCombine(version.packageInfo.resolvedPath, "CHANGELOG.md");
             return(IOProxy.FileExists(changelogFile) ? changelogFile : string.Empty);
         }
         catch (System.IO.IOException) {}
     }
     return(string.Empty);
 }