From 34857e16d7b826d4bf3f1c8da23a5d49aaa75aa5 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Fri, 7 Dec 2018 18:00:47 +0100 Subject: [PATCH 1/5] Create UpliftPreferences --- ...UpliftPreferences_UpliftSettings_Upset.cs} | 91 +++++++++++++------ ...tPreferences_UpliftSettings_Upset.cs.meta} | 6 +- .../Uplift/Schemas/UpliftPreferences.xsd | 19 ++++ .../Uplift/Schemas/UpliftPreferences.xsd.meta | 8 ++ 4 files changed, 95 insertions(+), 29 deletions(-) rename Assets/Plugins/Editor/Uplift/Schemas/{Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs => Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs} (93%) rename Assets/Plugins/Editor/Uplift/Schemas/{Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta => Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs.meta} (69%) create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd create mode 100644 Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd.meta diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs similarity index 93% rename from Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs rename to Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs index a67c935e..4e2f4600 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs @@ -1,31 +1,7 @@ -// --- BEGIN LICENSE BLOCK --- -/* - * Copyright (c) 2017-present WeWantToKnow AS - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// --- END LICENSE BLOCK --- - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // Ce code a été généré par un outil. -// Version du runtime :2.0.50727.8825 +// Version du runtime :2.0.50727.8937 // // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si // le code est régénéré. @@ -748,6 +724,69 @@ public string Location { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] + public partial class UpliftPreferences { + + private bool useExperimentalFeaturesField; + + private bool trustUnknowCertificatesField; + + private bool useGithubProxyField; + + private string githubProxyUrlField; + + public UpliftPreferences() { + this.useExperimentalFeaturesField = false; + this.trustUnknowCertificatesField = false; + this.useGithubProxyField = false; + } + + /// + public bool UseExperimentalFeatures { + get { + return this.useExperimentalFeaturesField; + } + set { + this.useExperimentalFeaturesField = value; + } + } + + /// + public bool TrustUnknowCertificates { + get { + return this.trustUnknowCertificatesField; + } + set { + this.trustUnknowCertificatesField = value; + } + } + + /// + public bool UseGithubProxy { + get { + return this.useGithubProxyField; + } + set { + this.useGithubProxyField = value; + } + } + + /// + public string GithubProxyUrl { + get { + return this.githubProxyUrlField; + } + set { + this.githubProxyUrlField = value; + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] diff --git a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs.meta similarity index 69% rename from Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta rename to Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs.meta index 8d697798..e0dc229e 100644 --- a/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftSettings_Upset.cs.meta +++ b/Assets/Plugins/Editor/Uplift/Schemas/Common_RepositoryTypes_Upbring_Upfile_UpliftPreferences_UpliftSettings_Upset.cs.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: 5339aac872f92114eae5f79f9e64ef45 -timeCreated: 1511774104 -licenseType: Free +guid: c817bfdf6649fc748b8ab375cc885c59 +timeCreated: 1544201972 +licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd b/Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd new file mode 100644 index 00000000..12036dbd --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd.meta b/Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd.meta new file mode 100644 index 00000000..61a9ade2 --- /dev/null +++ b/Assets/Plugins/Editor/Uplift/Schemas/UpliftPreferences.xsd.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d64072a15c12ee34d9059f9af27167f8 +timeCreated: 1544201972 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: From 2b1a96749acedf677b7631d646b17929d0e01bac Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Fri, 7 Dec 2018 18:31:54 +0100 Subject: [PATCH 2/5] Use new UpliftPreferences which relies on ~/.uplift/preferences.xml --- Assets/Plugins/Editor/Uplift/MenuItems.cs | 7 +- .../Editor/Uplift/UpliftPreferences.cs | 138 +++++++----------- Assets/Plugins/Editor/Uplift/Utils/GitHub.cs | 11 +- 3 files changed, 64 insertions(+), 92 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/MenuItems.cs b/Assets/Plugins/Editor/Uplift/MenuItems.cs index 102bd93b..3dff12d2 100644 --- a/Assets/Plugins/Editor/Uplift/MenuItems.cs +++ b/Assets/Plugins/Editor/Uplift/MenuItems.cs @@ -26,6 +26,7 @@ using UnityEngine; using Uplift.Windows; using Uplift.Common; +using Uplift.Schemas; using Uplift.Updating; using Uplift.Export; @@ -112,7 +113,7 @@ private static void InstallDependencies() [MenuItem("Tools/Uplift/Show Update Window (experimental)", true, 4)] private static bool EnableShowUpdateWindow() { - return UpliftPreferences.UseExperimental(); + return UpliftPreferences.FromDefaultFile().UseExperimentalFeatures; } [MenuItem("Tools/Uplift/Show Update Window (experimental)", false, 4)] @@ -125,8 +126,8 @@ private static void ShowUpdateWindow() [MenuItem("Tools/Uplift/Edit Upfile (experimental)", true, 101)] private static bool EnableEditUpfile() { - return UpliftPreferences.UseExperimental(); - } + return UpliftPreferences.FromDefaultFile().UseExperimentalFeatures; + } [MenuItem("Tools/Uplift/Edit Upfile (experimental)", false, 101)] private static void EditUpfile() diff --git a/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs b/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs index bbb78eb1..0481bb1e 100644 --- a/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs +++ b/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs @@ -23,101 +23,71 @@ // --- END LICENSE BLOCK --- using System; -using System.Text.RegularExpressions; -using UnityEditor; +using System.IO; using UnityEngine; +using Uplift.Common; -namespace Uplift +namespace Uplift.Schemas { - public class UpliftPreferences : MonoBehaviour - { - private static bool prefsLoaded = false; - private static readonly string useExperimentalFeaturesKey = "UpliftExperimentalFeatures"; - private static readonly string trustUnknownCertificatesKey = "UpliftUnknownCertificates"; - private static readonly string githubProxyUseKey = "UpliftGithubProxyUseKey"; - private static readonly string githubProxyUrlKey = "UpliftGithubProxyUrlKey"; + public partial class UpliftPreferences : MonoBehaviour + { + public static readonly string folderName = ".uplift"; + public static readonly string defaultFileName = "preferences.xml"; - private static bool useExperimentalFeatures; - private static bool trustUnknownCertificates; - private static bool useGithubProxy; - private static string githubProxyUrl; + public static UpliftPreferences FromDefaultFile() + { + return FromFile(GetDefaultLocation()); + } - [PreferenceItem("Uplift")] - public static void PreferencesGUI() - { - EnsurePrefsLoaded(); - EditorGUILayout.LabelField("SSL Certificates:", EditorStyles.boldLabel); - EditorGUILayout.HelpBox("Uplift uses SSL certificates when updating itself, as it fetches its update from Github with HTTPS", MessageType.Info); - EditorGUILayout.HelpBox( - "Unknown certificates could be the result of our registered certificates being outdated or the result of a potential attack. Trusting unknown certificates could lead to security breaches. Use at your own risk!", - MessageType.Warning - ); - trustUnknownCertificates = EditorGUILayout.Toggle("Trust unknown certificates", trustUnknownCertificates); + public static string GetDefaultLocation() + { + string sourceDir = System.IO.Path.Combine(GetHomePath(), folderName); + return System.IO.Path.Combine(sourceDir, defaultFileName); + } - EditorGUILayout.LabelField("Experimental features:", EditorStyles.boldLabel); - EditorGUILayout.HelpBox( - "Experimental features are not thoroughly tested and could induce bugs. Use at your own risk!", - MessageType.Warning - ); - useExperimentalFeatures = EditorGUILayout.Toggle("Use experimental features", useExperimentalFeatures); + public static UpliftPreferences FromFile(string source) + { + UpliftPreferences result = new UpliftPreferences(); - EditorGUILayout.LabelField("Github related:", EditorStyles.boldLabel); - EditorGUILayout.HelpBox( - "Github does not support TLS versions 1.0 and 1.1 as of 22/02/2018, and TLS 1.2 is available in Unity only with Mono 4.8. If you want to use a Github Repository, it will need to be behind a proxy", - MessageType.Info - ); - useGithubProxy = EditorGUILayout.Toggle("Use Github proxy", useGithubProxy); - GUI.enabled = useGithubProxy; - if (useGithubProxy) - EditorGUILayout.HelpBox( - "The proxy URL will replace 'https://api.github.com'", - MessageType.Info - ); - githubProxyUrl = EditorGUILayout.TextField("Proxy URL", githubProxyUrl); - githubProxyUrl = Regex.Replace(githubProxyUrl, "/$", ""); - GUI.enabled = true; + if (!File.Exists(source)) + { + Debug.Log("No local settings file detected at " + source); + return result; + } - if (GUI.changed) - { - EditorPrefs.SetBool(useExperimentalFeaturesKey, useExperimentalFeatures); - EditorPrefs.SetBool(trustUnknownCertificatesKey, trustUnknownCertificates); - EditorPrefs.SetBool(githubProxyUseKey, useGithubProxy); - EditorPrefs.SetString(githubProxyUrlKey, githubProxyUrl); - } - } + StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); - private static void EnsurePrefsLoaded() - { - if (!prefsLoaded) - { - useExperimentalFeatures = EditorPrefs.GetBool(useExperimentalFeaturesKey, false); - trustUnknownCertificates = EditorPrefs.GetBool(trustUnknownCertificatesKey, false); - useGithubProxy = EditorPrefs.GetBool(githubProxyUseKey, false); - githubProxyUrl = EditorPrefs.GetString(githubProxyUrlKey, ""); - prefsLoaded = true; - } - } + using (FileStream fs = new FileStream(source, FileMode.Open)) + { + try + { + result = deserializer.Deserialize(fs); + } + catch (InvalidOperationException) + { + Debug.LogError(string.Format("Global Override file at {0} is not well formed", source)); + return result; + } - public static bool UseExperimental() - { - EnsurePrefsLoaded(); - return EditorPrefs.GetBool(useExperimentalFeaturesKey, false); - } + return result; + } + } - public static bool TrustUnknownCertificates() - { - EnsurePrefsLoaded(); - return EditorPrefs.GetBool(trustUnknownCertificatesKey, false); - } + public static string GetHomePath() + { + return (Environment.OSVersion.Platform == PlatformID.Unix || + Environment.OSVersion.Platform == PlatformID.MacOSX) + ? Environment.GetEnvironmentVariable("HOME") + : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"); + } - public static string UseGithubProxy(string url) - { - EnsurePrefsLoaded(); - if (!useGithubProxy || string.IsNullOrEmpty(githubProxyUrl)) - return url; + public string GetProxiedUrl(string url) + { + if (!UseGithubProxy || string.IsNullOrEmpty(GithubProxyUrl)) + return url; - Debug.Log("Proxying github api with " + githubProxyUrl); - return url.Replace("https://api.github.com", githubProxyUrl); - } - } + Debug.Log("Proxying github api with " + GithubProxyUrl); + return url.Replace("https://api.github.com", GithubProxyUrl); + } + } } diff --git a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs index 93960a44..8739420c 100644 --- a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs +++ b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs @@ -32,6 +32,7 @@ using System.Security.Cryptography.X509Certificates; using System.Text; using UnityEngine; +using Uplift.Schemas; namespace Uplift.GitHubModule { @@ -249,7 +250,7 @@ public class GitHub public static IEnumerator LoadReleases(string url, string authToken = null) { - string proxiedUrl = UpliftPreferences.UseGithubProxy(url); + string proxiedUrl = UpliftPreferences.FromDefaultFile().GetProxiedUrl(url); WWW www = string.IsNullOrEmpty(authToken) ? new WWW (proxiedUrl) : @@ -346,7 +347,7 @@ SslPolicyErrors sslPolicyErrors X509Certificate[] githubCertificates = GetCertificates(); - if(!(githubCertificates.Any(cert => cert.GetCertHashString() == certificate.GetCertHashString()) || UpliftPreferences.TrustUnknownCertificates())) + if(!(githubCertificates.Any(cert => cert.GetCertHashString() == certificate.GetCertHashString()) || UpliftPreferences.FromDefaultFile().TrustUnknowCertificates)) { Debug.LogErrorFormat("The received certificate ({0}) is not known by Uplift. We cannot download the update package. You could update Uplift manually, or go to Preferences and set 'Trust unknown certificates' to true.", certificate.GetCertHashString()); Debug.Log("Known certificates are:"); @@ -379,9 +380,9 @@ public static Stream GetAssetStream(GitHubAsset asset) } public static Stream GetAssetStream(GitHubAsset asset, string token) { - string proxiedUrl = UpliftPreferences.UseGithubProxy(asset.apiURL); + string proxiedUrl = UpliftPreferences.FromDefaultFile().GetProxiedUrl(asset.apiURL); - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxiedUrl); + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxiedUrl); request.Method = "GET"; if(!string.IsNullOrEmpty(token)) request.Headers["Authorization"] = "token " + token; @@ -400,7 +401,7 @@ public static Stream GetAssetStream(GitHubAsset asset, string token) address = new Uri(response.GetResponseHeader("Location")); } - request = (HttpWebRequest)WebRequest.Create(UpliftPreferences.UseGithubProxy(address.OriginalString)); + request = (HttpWebRequest)WebRequest.Create(UpliftPreferences.FromDefaultFile().GetProxiedUrl(address.OriginalString)); request.Method = "GET"; request.UserAgent = "Uplift GithubRepository/1.0 - https://github.com/DragonBox/uplift"; HttpWebResponse finalResponse = (HttpWebResponse)request.GetResponse(); From b39e23337eff3da023769a3051190307cba852a6 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Tue, 18 Dec 2018 10:43:02 +0100 Subject: [PATCH 3/5] Refactor file loading --- .../Editor/Uplift/UpliftPreferences.cs | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs b/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs index 0481bb1e..d2f87e60 100644 --- a/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs +++ b/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs @@ -29,30 +29,41 @@ namespace Uplift.Schemas { - public partial class UpliftPreferences : MonoBehaviour + public partial class UpliftPreferences { public static readonly string folderName = ".uplift"; public static readonly string defaultFileName = "preferences.xml"; public static UpliftPreferences FromDefaultFile() { - return FromFile(GetDefaultLocation()); + UpliftPreferences result; + //if (TryLoadFromFile(GetProjectLocation(), out result)) + // return result; + if (TryLoadFromFile(GetGlobalLocation(), out result)) + return result; + + return new UpliftPreferences(); } - public static string GetDefaultLocation() + public static string GetGlobalLocation() { string sourceDir = System.IO.Path.Combine(GetHomePath(), folderName); return System.IO.Path.Combine(sourceDir, defaultFileName); } - public static UpliftPreferences FromFile(string source) + public static string GetProjectLocation() { - UpliftPreferences result = new UpliftPreferences(); + throw new NotImplementedException(); + } + + public static bool TryLoadFromFile(string source, out UpliftPreferences result) + { + result = new UpliftPreferences(); if (!File.Exists(source)) { - Debug.Log("No local settings file detected at " + source); - return result; + Debug.Log("No preferences file at " + source); + return false; } StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); @@ -66,10 +77,10 @@ public static UpliftPreferences FromFile(string source) catch (InvalidOperationException) { Debug.LogError(string.Format("Global Override file at {0} is not well formed", source)); - return result; + return false; } - return result; + return true; } } From 1ee8addf56ef0d21e1311aca91639f1622aa1e87 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Tue, 18 Dec 2018 11:00:27 +0100 Subject: [PATCH 4/5] Fix indentation --- Assets/Plugins/Editor/Uplift/MenuItems.cs | 2 +- Assets/Plugins/Editor/Uplift/Utils/GitHub.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/MenuItems.cs b/Assets/Plugins/Editor/Uplift/MenuItems.cs index 3dff12d2..30e6a414 100644 --- a/Assets/Plugins/Editor/Uplift/MenuItems.cs +++ b/Assets/Plugins/Editor/Uplift/MenuItems.cs @@ -127,7 +127,7 @@ private static void ShowUpdateWindow() private static bool EnableEditUpfile() { return UpliftPreferences.FromDefaultFile().UseExperimentalFeatures; - } + } [MenuItem("Tools/Uplift/Edit Upfile (experimental)", false, 101)] private static void EditUpfile() diff --git a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs index 8739420c..d0eabfe8 100644 --- a/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs +++ b/Assets/Plugins/Editor/Uplift/Utils/GitHub.cs @@ -250,7 +250,7 @@ public class GitHub public static IEnumerator LoadReleases(string url, string authToken = null) { - string proxiedUrl = UpliftPreferences.FromDefaultFile().GetProxiedUrl(url); + string proxiedUrl = UpliftPreferences.FromDefaultFile().GetProxiedUrl(url); WWW www = string.IsNullOrEmpty(authToken) ? new WWW (proxiedUrl) : @@ -380,9 +380,9 @@ public static Stream GetAssetStream(GitHubAsset asset) } public static Stream GetAssetStream(GitHubAsset asset, string token) { - string proxiedUrl = UpliftPreferences.FromDefaultFile().GetProxiedUrl(asset.apiURL); + string proxiedUrl = UpliftPreferences.FromDefaultFile().GetProxiedUrl(asset.apiURL); - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxiedUrl); + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(proxiedUrl); request.Method = "GET"; if(!string.IsNullOrEmpty(token)) request.Headers["Authorization"] = "token " + token; From eec2d98656302aeafc4b07f22f521127f8fbc1e2 Mon Sep 17 00:00:00 2001 From: Paul Niezborala Date: Tue, 18 Dec 2018 11:11:44 +0100 Subject: [PATCH 5/5] Prefrences: do not use a strict xmlserializer --- Assets/Plugins/Editor/Uplift/UpliftPreferences.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs b/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs index d2f87e60..bb6b8df8 100644 --- a/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs +++ b/Assets/Plugins/Editor/Uplift/UpliftPreferences.cs @@ -24,6 +24,7 @@ using System; using System.IO; +using System.Xml.Serialization; using UnityEngine; using Uplift.Common; @@ -66,13 +67,13 @@ public static bool TryLoadFromFile(string source, out UpliftPreferences result) return false; } - StrictXmlDeserializer deserializer = new StrictXmlDeserializer(); + XmlSerializer deserializer = new XmlSerializer(typeof(UpliftPreferences)); using (FileStream fs = new FileStream(source, FileMode.Open)) { try { - result = deserializer.Deserialize(fs); + result = deserializer.Deserialize(fs) as UpliftPreferences; } catch (InvalidOperationException) { @@ -82,6 +83,7 @@ public static bool TryLoadFromFile(string source, out UpliftPreferences result) return true; } + } public static string GetHomePath()