浏览代码

Merge pull request #267 from Unity-Technologies/zgh/fix_color_and_editable_text_bugs

Zgh/fix color and editable text bugs
/main
GitHub 3 年前
当前提交
3810f362
共有 3 个文件被更改,包括 17 次插入27 次删除
  1. 4
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  2. 24
      com.unity.uiwidgets/Runtime/painting/colors.cs
  3. 16
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs

4
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs


return style == DiagnosticsTreeStyle.singleLine;
}
public static bool FloatEqual(float left, float right) {
return Mathf.Abs(left - right) < precisionErrorTolerance;
public static bool FloatEqual(float left, float right, float precisionTolerance = precisionErrorTolerance) {
return Mathf.Abs(left - right) < precisionTolerance;
}
}

24
com.unity.uiwidgets/Runtime/painting/colors.cs


if (max == 0.0f || delta == 0.0f) {
hue = 0.0f;
}
else if (max == red) {
else if (foundation_.FloatEqual(max,red)) {
else if (max == green) {
else if (foundation_.FloatEqual(max,green)) {
else if (max == blue) {
else if (foundation_.FloatEqual(max,blue)) {
hue = 60.0f * (((red - green) / delta) + 4);
}

}
public static HSVColor fromColor(Color color) {
float red = color.red / 0xFF;
float green = color.green / 0xFF;
float blue = color.blue / 0xFF;
float red = (float)color.red / 0xFF;
float green = (float)color.green / 0xFF;
float blue = (float)color.blue / 0xFF;
float alpha = color.alpha / 0xFF;
float alpha = (float)color.alpha / 0xFF;
float hue = painting_._getHue(red, green, blue, max, delta);
float saturation = max == 0.0f ? 0.0f : delta / max;

}
public static HSLColor fromColor(Color color) {
float red = color.red / 0xFF;
float green = color.green / 0xFF;
float blue = color.blue / 0xFF;
float red = (float)color.red / 0xFF;
float green = (float)color.green / 0xFF;
float blue = (float)color.blue / 0xFF;
float alpha = color.alpha / 0xFF;
float alpha = (float)color.alpha / 0xFF;
float saturation = lightness == 1.0f
float saturation = foundation_.FloatEqual(lightness, 1.0f)
? 0.0f
: ((delta / (1.0f - Mathf.Abs(2.0f * lightness - 1.0f))).clamp(0.0f, 1.0f));
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);

16
com.unity.uiwidgets/Runtime/widgets/editable_text.cs


paste: true,
selectAll: true
);
inputFormatters = inputFormatters ?? new List<TextInputFormatter>();
List<TextInputFormatter> formatters = new List<TextInputFormatter>();
if (inputFormatters == null) {
formatters = inputFormatters;
}
inputFormatters = maxLines == 1
? new List<TextInputFormatter>() {
BlacklistingTextInputFormatter.singleLineFormatter,
}
: inputFormatters;
this.inputFormatters = inputFormatters?? new List<TextInputFormatter>();
foreach (var formatter in formatters) {
inputFormatters.Add(formatter);
}
this.inputFormatters.Add(BlacklistingTextInputFormatter.singleLineFormatter);
showCursor = showCursor ?? !readOnly;
this.readOnly = readOnly;

正在加载...
取消
保存