Skip to content

Commit 20a8475

Browse files
committed
Added InvariantCulture to float.Parse so that it always parses the correct "invariant" number format that unity usually spits out
1 parent 6b12117 commit 20a8475

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Editor/BuildLayout.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// https://github.com/pschraut/UnityAddressablesBuildLayoutExplorer
44
//
55
using System.Collections.Generic;
6+
using System.Globalization;
67
using UnityEngine;
78

89
namespace Oddworm.EditorFramework
@@ -589,25 +590,25 @@ long ParseSize(string size)
589590
if (size.EndsWith("GB", System.StringComparison.OrdinalIgnoreCase))
590591
{
591592
var s = size.Substring(0, size.Length - 2);
592-
return (long)(float.Parse(s) * 1024 * 1024 * 1024);
593+
return (long)(float.Parse(s, CultureInfo.InvariantCulture) * 1024 * 1024 * 1024);
593594
}
594595

595596
if (size.EndsWith("MB", System.StringComparison.OrdinalIgnoreCase))
596597
{
597598
var s = size.Substring(0, size.Length - 2);
598-
return (long)(float.Parse(s) * 1024 * 1024);
599+
return (long)(float.Parse(s, CultureInfo.InvariantCulture) * 1024 * 1024);
599600
}
600601

601602
if (size.EndsWith("KB", System.StringComparison.OrdinalIgnoreCase))
602603
{
603604
var s = size.Substring(0, size.Length - 2);
604-
return (long)(float.Parse(s) * 1024);
605+
return (long)(float.Parse(s, CultureInfo.InvariantCulture) * 1024);
605606
}
606607

607608
if (size.EndsWith("B", System.StringComparison.OrdinalIgnoreCase))
608609
{
609610
var s = size.Substring(0, size.Length - 1);
610-
return long.Parse(s);
611+
return long.Parse(s, CultureInfo.InvariantCulture);
611612
}
612613

613614
return -1;

0 commit comments

Comments
 (0)