diff --git a/Runtime/XChart/Mesh/ChartToolVectorArrows.cs b/Runtime/XChart/Mesh/ChartToolVectorArrows.cs
index dc20c7b..76273f8 100644
--- a/Runtime/XChart/Mesh/ChartToolVectorArrows.cs
+++ b/Runtime/XChart/Mesh/ChartToolVectorArrows.cs
@@ -85,7 +85,13 @@ namespace XericUI.XChart.Mesh
public Vector2 C;
public Vector2 D;
public float Depth;
+ /// 00/10 这一对边的颜色(线性时=起点色)
public Color Color;
+ /// 01/11 这一对边的颜色(只有线性用;=终点色)
+ public Color ColorTo;
+ /// true=沿杆渐变(杆),false=单色(头、退化点)。
+ /// 必须 public:嵌套类型的 private 成员**外层类也读不到**(C# 的这条反直觉,本项目踩过)
+ public bool Linear;
}
private static readonly Comparison s_FarToNear =
@@ -142,7 +148,10 @@ namespace XericUI.XChart.Mesh
for (int i = 0; i < m_Faces.Count; i++)
{
ArrowFace face = m_Faces[i];
- FillRenderer.AddFace(face.A, face.B, face.C, face.D, face.Color, face.Color);
+ if (face.Linear)
+ FillRenderer.AddFaceLinear(face.A, face.B, face.C, face.D, face.Color, face.ColorTo);
+ else
+ FillRenderer.AddFace(face.A, face.B, face.C, face.D, face.Color, face.Color);
}
FillRenderer.Apply();
}
@@ -236,15 +245,19 @@ namespace XericUI.XChart.Mesh
return true;
}
+ // 杆:沿杆渐变(起点一侧 ← 终点一侧)。BuildShaft 的绕序把 a/d 放在起点、b/c 放在末端,
+ // 而 AddFaceLinear 取的是"00/10 一色、01/11 一色"——这条配对由探针钉着,配错会横着染到杆宽上
m_Faces.Add(new ArrowFace
{
- A = shaftA, B = shaftB, C = shaftC, D = shaftD, Depth = depth, Color = startColor,
+ A = shaftA, B = shaftB, C = shaftC, D = shaftD,
+ Depth = depth, Color = startColor, ColorTo = endColor, Linear = true,
});
if (!withHead) return true;
m_Faces.Add(new ArrowFace
{
- A = headA, B = headB, C = headC, D = headD, Depth = depth, Color = endColor,
+ A = headA, B = headB, C = headC, D = headD,
+ Depth = depth, Color = endColor,
});
return true;
}
diff --git a/Runtime/XChart/Mesh/XChartMeshFillRenderer.cs b/Runtime/XChart/Mesh/XChartMeshFillRenderer.cs
index ac68320..34ac1db 100644
--- a/Runtime/XChart/Mesh/XChartMeshFillRenderer.cs
+++ b/Runtime/XChart/Mesh/XChartMeshFillRenderer.cs
@@ -6,6 +6,23 @@ using XericUI.Core;
namespace XericUI.XChart.Mesh
{
+ ///
+ /// 一个填充四边形怎么上色(纯枚举,住在预算算式旁边是为了让"几顶点"这条判据离线可验)。
+ ///
+ ///
+ /// - :四角同色(4 顶点 2 三角)。
+ /// - :四角一色 + 中心一色(5 顶点 4 三角,做浅淡的立体感)。
+ /// - :沿 00/10 ↔ 01/11 这一对边线性渐变(4 顶点 2 三角)——
+ /// 箭头杆"起点色 → 终点色"走的是这一档。
+ ///
+ ///
+ public enum XChartFaceFillKind
+ {
+ Flat = 0,
+ Radial = 1,
+ Linear = 2,
+ }
+
///
/// 顶点预算分块(纯算,离线可验)。
///
@@ -68,6 +85,17 @@ namespace XericUI.XChart.Mesh
}
return max;
}
+
+ ///
+ /// 一块面要几个顶点:只有径向渐变要多一个中心顶点(5 个、4 三角),
+ /// 平坦与线性渐变都是 4 顶点 2 三角。
+ ///
+ /// 分块预算吃的是这个数(65535 是每个 Graphic 各自的上限),所以它必须是单一定义:
+ /// 渲染侧按它写顶点、预算侧按它算块,两处各写一套就会出现"预算以为 4 个、实际发 5 个"
+ /// ——那种分块会在恰好卡线时撞上限。
+ ///
+ public static int VerticesPerFace(XChartFaceFillKind kind)
+ => kind == XChartFaceFillKind.Radial ? 5 : 4;
}
///
@@ -90,6 +118,8 @@ namespace XericUI.XChart.Mesh
public Vector2 Corner10;
public Color32 EdgeColor;
public Color32 CenterColor;
+ /// 怎么上色(平坦 / 径向 / 线性)。 吃它
+ public XChartFaceFillKind Kind;
}
/// 一块:只画 [Start, End) 之间的面。顶点数受预算限制,所以不会撞 65535 上限。
@@ -138,6 +168,7 @@ namespace XericUI.XChart.Mesh
public void AddFace(Vector2 corner00, Vector2 corner01, Vector2 corner11, Vector2 corner10,
Color edgeColor, Color centerColor)
{
+ bool gradient = edgeColor != centerColor;
m_Faces.Add(new FaceQuad
{
Corner00 = corner00,
@@ -146,6 +177,31 @@ namespace XericUI.XChart.Mesh
Corner10 = corner10,
EdgeColor = edgeColor,
CenterColor = centerColor,
+ Kind = gradient ? XChartFaceFillKind.Radial : XChartFaceFillKind.Flat,
+ });
+ }
+
+ ///
+ /// 追加一个线性渐变的四边形:corner00 与 corner10 取
+ /// ,corner01 与 corner11 取
+ /// ——也就是"一对边一色",渐变方向垂直于那两条边。
+ ///
+ /// 箭头杆用的就是这一档: 绕出来的四角里
+ /// a/d 在起点一侧、b/c 在末端一侧(这条配对由探针钉着,配错就会横着染到杆的宽度上,
+ /// 画面上看是"杆的两侧各一色"而不是"沿杆渐变")。顶点数与平坦一样(4 个、2 三角)。
+ ///
+ public void AddFaceLinear(Vector2 corner00, Vector2 corner01, Vector2 corner11, Vector2 corner10,
+ Color fromColor, Color toColor)
+ {
+ m_Faces.Add(new FaceQuad
+ {
+ Corner00 = corner00,
+ Corner01 = corner01,
+ Corner11 = corner11,
+ Corner10 = corner10,
+ EdgeColor = fromColor,
+ CenterColor = toColor,
+ Kind = XChartFaceFillKind.Linear,
});
}
@@ -161,7 +217,7 @@ namespace XericUI.XChart.Mesh
{
if (m_FaceVertexCounts.Length < m_Faces.Count) m_FaceVertexCounts = new int[m_Faces.Count];
for (int i = 0; i < m_Faces.Count; i++)
- m_FaceVertexCounts[i] = IsGradient(m_Faces[i]) ? 5 : 4;
+ m_FaceVertexCounts[i] = XChartMeshBudget.VerticesPerFace(m_Faces[i].Kind);
if (m_ChunkStarts.Length < m_Faces.Count + 1) m_ChunkStarts = new int[m_Faces.Count + 1];
int chunks = XChartMeshBudget.Split(m_FaceVertexCounts, m_Faces.Count,
@@ -218,12 +274,18 @@ namespace XericUI.XChart.Mesh
FaceQuad face = m_Faces[i];
int first = vh.currentVertCount;
+ // 线性渐变:00/10 这一对取 from(EdgeColor),01/11 取 to(CenterColor);
+ // 平坦与径向都是四角同色(径向另加一个中心顶点)
+ bool linear = face.Kind == XChartFaceFillKind.Linear;
+ Color32 corner01Color = linear ? face.CenterColor : face.EdgeColor;
+ Color32 corner11Color = linear ? face.CenterColor : face.EdgeColor;
+
vh.AddVert(face.Corner00, face.EdgeColor, new Vector2(0f, 0f));
- vh.AddVert(face.Corner01, face.EdgeColor, new Vector2(0f, 1f));
- vh.AddVert(face.Corner11, face.EdgeColor, new Vector2(1f, 1f));
+ vh.AddVert(face.Corner01, corner01Color, new Vector2(0f, 1f));
+ vh.AddVert(face.Corner11, corner11Color, new Vector2(1f, 1f));
vh.AddVert(face.Corner10, face.EdgeColor, new Vector2(1f, 0f));
- if (IsGradient(face))
+ if (face.Kind == XChartFaceFillKind.Radial)
{
Vector2 center = (face.Corner00 + face.Corner01 + face.Corner11 + face.Corner10) * 0.25f;
vh.AddVert(center, face.CenterColor, new Vector2(0.5f, 0.5f));