XChart P20b:132 个旋钮全部"设了就生效"——122 个自动置脏,10 个走各自的 Sync

外部数据驱动缺的那一半:工具的参数以前是裸自动属性,写进去值在、画面不动,
必须再记得叫一次 MarkDirty()(他 2026-10-26 的原话:"设置的同时,属性就会自动完成脏标记")。
现在 9 个工具里每一个可写属性的 setter 都自己送变化:

    public float Radius { get => m_Radius; set { m_Radius = value; MarkDirty(); } }

覆盖不是"改了我记得的那几个",是源码门数的(.ximage-gate/dirty_gate.py):
knobs=132 takesEffect=132 —— 122 支经 MarkDirty、10 支(散点外观)经 SyncShapeParams。
那 10 支是本轮门**查出来的**,不是我原本知道的:它们早已自带生效路径,
所以判据从"必须调 MarkDirty"改成"必须调到本文件里定义的 MarkDirty 或 Sync*/Push*/Apply*/Rebuild*"。
门另两条顺手立的判据:
- E 支:setter 靠 Sync 生效的,OnInitialize 里也必须有那一句——否则
  "if (IsInitialized) Sync()" 会把初始化之前的写全丢;
- D 支:工具自己不许在 setter 之外给自己的旋钮赋值——那会在渲染过程中把自己重新置脏、每帧重建。
  这一支第一轮报了 26 处"自赋值",全是渲染器属性的 { get; private set; }:那是只读投影不是旋钮,
  归进 views(14 个)后 0 处——真违规的一处没有(写了这条判据才知道有没有)。
  同轮另一处假红是判据把标识符里的字母当成了关键字:Offset 拼出来含 "set",
  于是只读的 Offset 被读成"有个从不调用置脏的 setter"⇒ 访问器判定改成词边界 \bset\b。
七支变异全红:M1 抹掉一个 setter 的 MarkDirty、M2 把 override 拿掉(CS0108 只是警告,
通过基类的调用从此静默失效)、M3 新增一个裸自动属性、M4 工具自赋值、M5 把一个工具从磁盘上挪走
(清单两侧都数)、M6 Sync 调用改成不存在的名字、M7 从 OnInitialize 里删掉那句 Sync。

自己的批量改写脚本先写错了一处,被门和编译门各抓一次:生成的字段行漏了等号
(private float m_Radius 0.22f;),121 个字段全中。修法是逐字节再走一遍
(.ximage-gate/knob_dirty_fix.py:判据是"这种形状的行了 0"而不是"看着差不多了")。
教训记进规范:批量改写后**先比"我说改了几处"与"实际几处合规"**,两侧都数。

ChartToolSpace 的 Rotation 初始化式跨两行,脚本按"同一行没闭合就拒绝整份"跳过了整个文件,
那 4 个旋钮手改——拒绝写比写一半好。

离线编译门(runtime + player + editor + 3 支对照):GATE PASSED,chain_p20b.txt rc=0。
mono 数学探针本轮不重跑:改的全是 MonoBehaviour 侧工具的 setter,纯算文件一个没动。
This commit is contained in:
2026-10-26 09:02:13 +08:00
parent 71629c08bf
commit 4272406330
9 changed files with 245 additions and 123 deletions
+56 -28
View File
@@ -43,62 +43,90 @@ namespace XericUI.XChart.Axis
{
// ── 宿主与走向 ────────────────────────────────────────────
private string m_SlotId = XChartCubeGeometry.FaceSlotId(XChartCubeGeometry.CubeFace.Bottom);
/// <summary>
/// 宿主面用**插槽 id** 指定(规范 §11.2):默认取定义网格发布的 <c>mesh.face.&lt;面号&gt;</c>。
/// 不再认"第几个面"——拿到的是点,所以异形网格只要发布同 id 的插槽就能用。
/// </summary>
public string SlotId { get; set; } = XChartCubeGeometry.FaceSlotId(XChartCubeGeometry.CubeFace.Bottom);
public string SlotId { get => m_SlotId; set { m_SlotId = value; MarkDirty(); } }
private bool m_AlignToGrid;
/// <summary>
/// 对齐格线(P9):开启后每条主刻度的位置会<b>吸附到网格发布的那组线上</b>
/// (轴沿 S 走读 <c>grid.T</c>、沿 T 走读 <c>grid.S</c>),偏移超过"相邻两条线间距的一半"
/// 就不吸。网格是定义方,这里只是跟随。
/// </summary>
public bool AlignToGrid { get; set; }
public XChartAxisDirection Direction { get; set; } = XChartAxisDirection.AlongS;
public float StartRatio { get; set; }
public float EndRatio { get; set; } = 1f;
public float CrossRatio { get; set; }
public XChartToolTransform Transform { get; set; } = XChartToolTransform.Identity;
public bool AlignToGrid { get => m_AlignToGrid; set { m_AlignToGrid = value; MarkDirty(); } }
private XChartAxisDirection m_Direction = XChartAxisDirection.AlongS;
public XChartAxisDirection Direction { get => m_Direction; set { m_Direction = value; MarkDirty(); } }
private float m_StartRatio;
public float StartRatio { get => m_StartRatio; set { m_StartRatio = value; MarkDirty(); } }
private float m_EndRatio = 1f;
public float EndRatio { get => m_EndRatio; set { m_EndRatio = value; MarkDirty(); } }
private float m_CrossRatio;
public float CrossRatio { get => m_CrossRatio; set { m_CrossRatio = value; MarkDirty(); } }
private XChartToolTransform m_Transform = XChartToolTransform.Identity;
public XChartToolTransform Transform { get => m_Transform; set { m_Transform = value; MarkDirty(); } }
// ── 值域与刻度 ────────────────────────────────────────────
private int m_Dimension;
/// <summary>
/// 轴读哪一维——这是<b>绑定</b>(这条轴画的是哪一路数据),不是范围。
/// 范围与"这一维现在有没有数据"归 chart 的数据板块(每个维度一行),
/// 工具只呈现(规范 §1)。
/// </summary>
public int Dimension { get; set; }
public int Dimension { get => m_Dimension; set { m_Dimension = value; MarkDirty(); } }
public XChartAxisScale Scale { get; set; } = XChartAxisScale.Linear;
public double ExponentialStrength { get; set; } = 2.0;
public bool AutoStep { get; set; } = true;
public double ManualStep { get; set; } = 1.0;
public int TargetMajorCount { get; set; } = 5;
public int MinorTickCount { get; set; } = 4;
private XChartAxisScale m_Scale = XChartAxisScale.Linear;
public XChartAxisScale Scale { get => m_Scale; set { m_Scale = value; MarkDirty(); } }
private double m_ExponentialStrength = 2.0;
public double ExponentialStrength { get => m_ExponentialStrength; set { m_ExponentialStrength = value; MarkDirty(); } }
private bool m_AutoStep = true;
public bool AutoStep { get => m_AutoStep; set { m_AutoStep = value; MarkDirty(); } }
private double m_ManualStep = 1.0;
public double ManualStep { get => m_ManualStep; set { m_ManualStep = value; MarkDirty(); } }
private int m_TargetMajorCount = 5;
public int TargetMajorCount { get => m_TargetMajorCount; set { m_TargetMajorCount = value; MarkDirty(); } }
private int m_MinorTickCount = 4;
public int MinorTickCount { get => m_MinorTickCount; set { m_MinorTickCount = value; MarkDirty(); } }
// ── 外观 ──────────────────────────────────────────────────
public Color LineColor { get; set; } = new Color(0.85f, 0.88f, 0.95f, 0.9f);
public float LineThickness { get; set; } = 2f;
public float MajorTickLength { get; set; } = 8f;
public float MinorTickLength { get; set; } = 4f;
public float TickThickness { get; set; } = 1.5f;
private Color m_LineColor = new Color(0.85f, 0.88f, 0.95f, 0.9f);
public Color LineColor { get => m_LineColor; set { m_LineColor = value; MarkDirty(); } }
private float m_LineThickness = 2f;
public float LineThickness { get => m_LineThickness; set { m_LineThickness = value; MarkDirty(); } }
private float m_MajorTickLength = 8f;
public float MajorTickLength { get => m_MajorTickLength; set { m_MajorTickLength = value; MarkDirty(); } }
private float m_MinorTickLength = 4f;
public float MinorTickLength { get => m_MinorTickLength; set { m_MinorTickLength = value; MarkDirty(); } }
private float m_TickThickness = 1.5f;
public float TickThickness { get => m_TickThickness; set { m_TickThickness = value; MarkDirty(); } }
private float m_TickSide = -1f;
/// <summary>刻度朝哪边:+1 朝面参数增大方向,-1 朝减小方向</summary>
public float TickSide { get; set; } = -1f;
public float TickSide { get => m_TickSide; set { m_TickSide = value; MarkDirty(); } }
// ── 标签 ──────────────────────────────────────────────────
public XChartAxisLabelSource LabelSource { get; set; } = XChartAxisLabelSource.TickValue;
private XChartAxisLabelSource m_LabelSource = XChartAxisLabelSource.TickValue;
public XChartAxisLabelSource LabelSource { get => m_LabelSource; set { m_LabelSource = value; MarkDirty(); } }
private string m_LabelFormat;
/// <summary>数值格式化串(如 "0.00" 或 "0.#");留空走自适应</summary>
public string LabelFormat { get; set; }
public string[] CustomLabels { get; set; }
public float LabelGap { get; set; } = 6f;
public float LabelFontSize { get; set; } = 14f;
public Color LabelColor { get; set; } = new Color(0.85f, 0.88f, 0.95f, 0.95f);
public Vector2 LabelSize { get; set; } = new Vector2(90f, 24f);
public string LabelFormat { get => m_LabelFormat; set { m_LabelFormat = value; MarkDirty(); } }
private string[] m_CustomLabels;
public string[] CustomLabels { get => m_CustomLabels; set { m_CustomLabels = value; MarkDirty(); } }
private float m_LabelGap = 6f;
public float LabelGap { get => m_LabelGap; set { m_LabelGap = value; MarkDirty(); } }
private float m_LabelFontSize = 14f;
public float LabelFontSize { get => m_LabelFontSize; set { m_LabelFontSize = value; MarkDirty(); } }
private Color m_LabelColor = new Color(0.85f, 0.88f, 0.95f, 0.95f);
public Color LabelColor { get => m_LabelColor; set { m_LabelColor = value; MarkDirty(); } }
private Vector2 m_LabelSize = new Vector2(90f, 24f);
public Vector2 LabelSize { get => m_LabelSize; set { m_LabelSize = value; MarkDirty(); } }
private bool m_RotateLabelsWithAxis = true;
/// <summary>标签跟着轴的方向转(斜面上读起来才不拧着)</summary>
public bool RotateLabelsWithAxis { get; set; } = true;
public bool RotateLabelsWithAxis { get => m_RotateLabelsWithAxis; set { m_RotateLabelsWithAxis = value; MarkDirty(); } }
// ── 内部 ──────────────────────────────────────────────────