From 20a84754e977550ca370e02d4df80820418430c6 Mon Sep 17 00:00:00 2001 From: Oliver Iking Date: Tue, 8 Mar 2022 10:21:11 +0100 Subject: [PATCH] Added InvariantCulture to float.Parse so that it always parses the correct "invariant" number format that unity usually spits out --- Editor/BuildLayout.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Editor/BuildLayout.cs b/Editor/BuildLayout.cs index 3935db0..c047b38 100644 --- a/Editor/BuildLayout.cs +++ b/Editor/BuildLayout.cs @@ -3,6 +3,7 @@ // https://github.com/pschraut/UnityAddressablesBuildLayoutExplorer // using System.Collections.Generic; +using System.Globalization; using UnityEngine; namespace Oddworm.EditorFramework @@ -589,25 +590,25 @@ long ParseSize(string size) if (size.EndsWith("GB", System.StringComparison.OrdinalIgnoreCase)) { var s = size.Substring(0, size.Length - 2); - return (long)(float.Parse(s) * 1024 * 1024 * 1024); + return (long)(float.Parse(s, CultureInfo.InvariantCulture) * 1024 * 1024 * 1024); } if (size.EndsWith("MB", System.StringComparison.OrdinalIgnoreCase)) { var s = size.Substring(0, size.Length - 2); - return (long)(float.Parse(s) * 1024 * 1024); + return (long)(float.Parse(s, CultureInfo.InvariantCulture) * 1024 * 1024); } if (size.EndsWith("KB", System.StringComparison.OrdinalIgnoreCase)) { var s = size.Substring(0, size.Length - 2); - return (long)(float.Parse(s) * 1024); + return (long)(float.Parse(s, CultureInfo.InvariantCulture) * 1024); } if (size.EndsWith("B", System.StringComparison.OrdinalIgnoreCase)) { var s = size.Substring(0, size.Length - 1); - return long.Parse(s); + return long.Parse(s, CultureInfo.InvariantCulture); } return -1;