From 6254c6ea0b81e6f555f8afe0f9200233ae6d8614 Mon Sep 17 00:00:00 2001 From: JoC0de <53140583+JoC0de@users.noreply.github.com> Date: Sat, 21 Jan 2023 20:52:15 +0100 Subject: [PATCH] Resolve deprecated code warnings --- src/NuGetForUnity/Editor/NugetPreferences.cs | 23 +++++++++++++++++--- src/NuGetForUnity/Editor/NugetWindow.cs | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/NuGetForUnity/Editor/NugetPreferences.cs b/src/NuGetForUnity/Editor/NugetPreferences.cs index 1126b45d..48096c4b 100644 --- a/src/NuGetForUnity/Editor/NugetPreferences.cs +++ b/src/NuGetForUnity/Editor/NugetPreferences.cs @@ -6,7 +6,7 @@ namespace NugetForUnity /// /// Handles the displaying, editing, and saving of the preferences for NuGet For Unity. /// - public static class NugetPreferences + public class NugetPreferences : SettingsProvider { /// /// The current version of NuGet for Unity. @@ -18,11 +18,28 @@ public static class NugetPreferences /// private static Vector2 scrollPosition; + /// + /// Instantiate the settings provider. + /// + public NugetPreferences() + : base("Preferences/NuGet For Unity", SettingsScope.User) + { + } + + /// + /// Creates a instance of the NuGet for Unity settings provider. + /// + /// The instance of the settings provider. + [SettingsProvider] + public static SettingsProvider Create() + { + return new NugetPreferences(); + } + /// /// Draws the preferences GUI inside the Unity preferences window in the Editor. /// - [PreferenceItem("NuGet For Unity")] - public static void PreferencesGUI() + public override void OnGUI(string searchContext) { var preferencesChangedThisFrame = false; diff --git a/src/NuGetForUnity/Editor/NugetWindow.cs b/src/NuGetForUnity/Editor/NugetWindow.cs index 34a476cf..4f99d6f0 100644 --- a/src/NuGetForUnity/Editor/NugetWindow.cs +++ b/src/NuGetForUnity/Editor/NugetWindow.cs @@ -190,7 +190,7 @@ protected static void CheckForUpdates() string latestVersion = null; string latestVersionDownloadUrl = null; string response = null; - if (!request.isNetworkError && !request.isHttpError) + if (string.IsNullOrEmpty(request.error)) { response = request.downloadHandler.text; } @@ -327,7 +327,7 @@ private void Refresh(bool forceFullRefresh) } catch (Exception e) { - Debug.LogErrorFormat("Error while refreshing NuGet packages list: {0}", e.ToString()); + Debug.LogErrorFormat("Error while refreshing NuGet packages list: {0}", e); } finally {