Fix UI Toolkit border width lowering
This commit is contained in:
parent
82ac8c8163
commit
8327e4d3db
1 changed files with 16 additions and 1 deletions
|
|
@ -362,7 +362,7 @@ namespace GameCult.Eve.UnityUIToolkit
|
|||
if (TryGet(style, "color", out var color) && TryParseColor(color, out var textColor))
|
||||
element.style.color = textColor;
|
||||
if (TryGet(style, "borderWidth", out var borderWidth))
|
||||
ApplyBoxLength(borderWidth, value =>
|
||||
ApplyBoxFloat(borderWidth, value =>
|
||||
{
|
||||
element.style.borderTopWidth = value;
|
||||
element.style.borderRightWidth = value;
|
||||
|
|
@ -416,11 +416,26 @@ namespace GameCult.Eve.UnityUIToolkit
|
|||
return StyleKeyword.Null;
|
||||
}
|
||||
|
||||
private static StyleFloat ParseFloat(string value)
|
||||
{
|
||||
value = FirstToken(value);
|
||||
if (value.EndsWith("px", StringComparison.OrdinalIgnoreCase))
|
||||
value = value.Substring(0, value.Length - 2);
|
||||
return float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var pixels)
|
||||
? pixels
|
||||
: StyleKeyword.Null;
|
||||
}
|
||||
|
||||
private static void ApplyBoxLength(string value, Action<StyleLength> apply)
|
||||
{
|
||||
apply(ParseLength(value));
|
||||
}
|
||||
|
||||
private static void ApplyBoxFloat(string value, Action<StyleFloat> apply)
|
||||
{
|
||||
apply(ParseFloat(value));
|
||||
}
|
||||
|
||||
private static bool TryParseColor(string value, out Color color)
|
||||
{
|
||||
value = value.Trim();
|
||||
|
|
|
|||
Loading…
Reference in a new issue