internal static Color ValueCheck(Color color)
{
- return new Color(InvalidChecker(color.R), InvalidChecker(color.G), InvalidChecker(color.B), InvalidChecker(color.A));
+ float r = color.R;
+ float g = color.G;
+ float b = color.B;
+ float a = color.A;
+
+ if (r < 0.0f)
+ {
+ r = 0.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ else if (r > 1.0f)
+ {
+ r = 1.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ if (g < 0.0f)
+ {
+ g = 0.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ else if (g > 1.0f)
+ {
+ g = 1.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ if (b < 0.0f)
+ {
+ b = 0.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ else if (b > 1.0f)
+ {
+ b = 1.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ if (a < 0.0f)
+ {
+ a = 0.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ else if (a > 1.0f)
+ {
+ a = 1.0f;
+ NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
+ }
+ color = new Color(r, g, b, a);
+ return color;
}
internal static float ValueCheck(float value)
{
- return InvalidChecker(value);
+ if (value < 0.0f)
+ {
+ value = 0.0f;
+ NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
+ }
+ else if (value > 1.0f)
+ {
+ value = 1.0f;
+ NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
+ }
+ return value;
}
internal static float[] ValueCheck(float[] arr)
for (int i = 0; i < arr.Length; i++)
{
- arr[i] = InvalidChecker(arr[i]);
+ if (arr[i] < 0.0f)
+ {
+ arr[i] = 0.0f;
+ NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
+ }
+ else if (arr[i] > 1.0f)
+ {
+ arr[i] = 1.0f;
+ NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
+ }
}
return arr;
}
-
- private static float InvalidChecker(float value)
- {
- if (value < 0.0f)
- {
- value = 0.0f;
- NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. value is {value}");
- }
- else if(value > 1.0f)
- {
- value = 1.0f;
- NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. value is {value}");
- }
- return value;
- }
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]