From 17c6330d51a140eac037b9ea6f5d157a846535af Mon Sep 17 00:00:00 2001 From: Igor Stojkovic Date: Fri, 22 Dec 2023 10:58:23 +0100 Subject: [PATCH] Fixed caching for http iconUrls on Unity2022 --- .../Editor/Helper/NugetPackageTextureHelper.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs b/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs index 0ba8a5ab..58de7198 100644 --- a/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs +++ b/src/NuGetForUnity/Editor/Helper/NugetPackageTextureHelper.cs @@ -41,6 +41,15 @@ internal static Task DownloadImageAsync([NotNull] string url) { try { +#if UNITY_2022_1_OR_NEWER + if (PlayerSettings.insecureHttpOption == InsecureHttpOption.NotAllowed && + url.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) + { + // if insecure http url is not allowed try to use https. + url = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase); + } +#endif + var fromCache = false; if (url.StartsWith("file://", StringComparison.OrdinalIgnoreCase)) { @@ -53,15 +62,6 @@ internal static Task DownloadImageAsync([NotNull] string url) fromCache = true; } -#if UNITY_2022_1_OR_NEWER - if (PlayerSettings.insecureHttpOption == InsecureHttpOption.NotAllowed && - url.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) - { - // if insecure http url is not allowed try to use https. - url = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase); - } -#endif - var taskCompletionSource = new TaskCompletionSource(); var request = UnityWebRequest.Get(url); {