Skip to content

Commit

Permalink
fix: #2, #4 Decimal points are not entered correctly when mouse dragg…
Browse files Browse the repository at this point in the history
…ing in some cultures
  • Loading branch information
fuqunaga committed Nov 15, 2022
1 parent 3c68556 commit 17f7f7a
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
namespace RosettaUI.UIToolkit.UnityInternalAccess
using System.Globalization;

namespace RosettaUI.UIToolkit.UnityInternalAccess
{
public sealed class EditorGUI
{
internal static string kFloatFieldFormatString = "g7";
// internal static readonly string s_AllowedCharactersForFloat = "inftynaeINFTYNAE0123456789.,-*/+%^()cosqrludxvRL=pP#";
internal static readonly string s_AllowedCharactersForFloat = "0123456789.-+";

public static void StringToDouble(string str, out double num)

// ref: https://github.com/Unity-Technologies/UnityCsReference/blob/79d86f859b8454fcacc96962eb6e455cf6cd4f45/Runtime/Export/ExpressionEvaluator.cs#L508
public static bool StringToDouble(string str, out double num)
{
double.TryParse(str, out num);
return double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out num);
}

internal static string kIntFieldFormatString = "#######0";
internal static readonly string s_AllowedCharactersForInt = "0123456789-+";

internal static bool StringToLong(string str, out long value) => long.TryParse(str, out value);
// ref: https://github.com/Unity-Technologies/UnityCsReference/blob/79d86f859b8454fcacc96962eb6e455cf6cd4f45/Runtime/Export/ExpressionEvaluator.cs#L514
internal static bool StringToLong(string str, out long value)
{
return long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture.NumberFormat, out value);
}
}
}

0 comments on commit 17f7f7a

Please sign in to comment.