compatibility

This commit is contained in:
monitor1394
2022-01-07 09:48:59 +08:00
parent 228a4b2840
commit 0282dae582
9 changed files with 50 additions and 16 deletions

View File

@@ -373,9 +373,25 @@ namespace XUGL
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
public static void DrawZebraLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
float zebraWidth, float zebraGap, Color32 color, Color32 toColor)
float zebraWidth, float zebraGap, Color32 color, Color32 toColor, float maxDistance)
{
DrawDotLine(vh, startPoint, endPoint, width, color, toColor, zebraWidth, zebraGap);
var dist = Vector3.Distance(startPoint, endPoint);
if (dist < 0.1f) return;
if (zebraWidth == 0) zebraWidth = 3 * width;
if (zebraGap == 0) zebraGap = 3 * width;
var allSegment = Mathf.CeilToInt(maxDistance / (zebraWidth + zebraGap));
var segment = Mathf.CeilToInt(dist / maxDistance * allSegment);
var dir = (endPoint - startPoint).normalized;
var sp = startPoint;
var np = Vector3.zero;
var isGradient = !color.Equals(toColor);
zebraWidth = (maxDistance - zebraGap * (allSegment - 1)) / allSegment;
for (int i = 1; i <= segment; i++)
{
np = sp + dir * zebraWidth;
DrawLine(vh, sp, np, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / allSegment) : color);
sp = np + dir * zebraGap;
}
}
/// <summary>