P26:标签按"标签列"1:1 落到记录、窗口、元素、文本四处(规范 §35)
- XChartColumnMath 补标签半边(LabelCount / LabelSlotOf / DefinitionOfLabelSlot / SizedLabels),
记录的标签长度只由这一处定;TryAddRecord 在 labels 长度≠标签列数时整条拒收
- 导入按标签字段个数校验并点名行号;记录行少到连时间戳都没有时点名拒绝(不再抛异常)
- 数据窗口:一个显示序两个读者(标签列在前),格子身份 CellRef{IsLabel,Slot},
标签格走 TrySetLabel 的字符串分支,「+标签」走 SetDimensions 这唯一定长路径
- 新标签元素 ChartToolLabels + XChartLabelConfig:13 旋钮全自动置脏、位置/折法同散点、
文本走池且多余槽位必须擦、锚点与对齐出自同一张表(anchorMin/Max 不写)
- 面板把"要几个标签列、表里有几个"与数值维、记录数一起印(§25.1 第三半 RequiredLabelColumns)
- 探针先红的两个真缺陷:SizedLabels(null,n) 补 null 不是空串;锚点表漏 MiddleRight 与 Center 重合
- 雷达 AddSeries 带系列名,两个 SetDimensions 重载都声明 series 标签列(否则新门口整条拒收)
- 判据:探针 492/0、label_gate 15 claim/15 臂全红、dirty_gate 149/149、slot_reset PASS、
编译门三臂+3 对照绿(source present 点名四个新文件)、p4_control 78 支各红在点名断言
(同一棵树指纹 478727e6748c67cddda40995874b20968e9eae3706f2a21c24726d3412059747)
This commit is contained in:
@@ -0,0 +1,268 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using XericUI.Core;
|
||||
using XericUI.XChart.Space;
|
||||
|
||||
namespace XericUI.XChart.Text
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据标签元素:一条记录一个标签,标签读的是那一行在<b>某一标签列</b>上的字符串。
|
||||
///
|
||||
/// <para><b>1:1 是结构保证而不是约定</b>:记录身上的标签数组长度=标签列个数,
|
||||
/// 所以这一列读得到的就是那一行的那一格;比列更多的字符串没有列叫得出它的名字,
|
||||
/// 它在窗口里显示得出来、元素读不到(口径只有一份:<see cref="XChartColumnMath"/>)。
|
||||
/// 一条记录配几个数值维+一个字符串维,画面上就是"点+它自己的名字"。</para>
|
||||
///
|
||||
/// <para><b>位置从哪儿来</b>:和散点/圆柱/矢量场<b>同一个</b>空间与同一份折法
|
||||
/// (<see cref="XChartCubeFoldMath"/>),显示范围只定标尺;超范围怎么办由这一档自己决定(§32)。
|
||||
/// <b>显示从哪儿来</b>:文本槽位池(运行时里唯一造 TMP 标签的地方),一件对应一条记录。</para>
|
||||
///
|
||||
/// <para><b>锚点和对齐出自同一张表</b>:贴在左下角却把字居中,字就会横跨在那一点两侧。
|
||||
/// 锚点决定矩形从哪一侧从点起排,对齐由同一个锚点算出来(<see cref="XChartLabelAnchorMath"/>)。</para>
|
||||
///
|
||||
/// 子节点结构:
|
||||
/// [Labels]
|
||||
/// └─ GeneratedTexts(文本槽位的宿主)
|
||||
/// </summary>
|
||||
[AddComponentMenu(XericRegistrationPaths.Chart + "/Text/Data Label Tool")]
|
||||
public class ChartToolLabels : XChartToolBase
|
||||
{
|
||||
// ── 数据装配 ──────────────────────────────────────────────
|
||||
|
||||
private int m_LabelSlot;
|
||||
/// <summary>读第几个<b>标签列</b>(不是表里的行号;换算只有 <see cref="XChartColumnMath.LabelSlotOf"/> 那一处)</summary>
|
||||
public int LabelSlot { get => m_LabelSlot; set { m_LabelSlot = value; MarkDirty(); } }
|
||||
|
||||
private int m_DimensionX;
|
||||
/// <summary>标签挂在哪条记录的哪一个位置:三个数值维下标(显示范围归 chart 的数据维度行)</summary>
|
||||
public int DimensionX { get => m_DimensionX; set { m_DimensionX = value; MarkDirty(); } }
|
||||
private int m_DimensionY = 1;
|
||||
public int DimensionY { get => m_DimensionY; set { m_DimensionY = value; MarkDirty(); } }
|
||||
private int m_DimensionZ = 2;
|
||||
public int DimensionZ { get => m_DimensionZ; set { m_DimensionZ = value; MarkDirty(); } }
|
||||
|
||||
private XChartToolTransform m_Transform = XChartToolTransform.Identity;
|
||||
public XChartToolTransform Transform { get => m_Transform; set { m_Transform = value; MarkDirty(); } }
|
||||
|
||||
private XChartValueOutOfRange m_OutOfRange = XChartValueOutOfRange.RenderAsIs;
|
||||
/// <summary>标签的位置受显示范围之外的影响时怎么办(§32:范围只定标尺,画不画由数据图元自己决定)</summary>
|
||||
public XChartValueOutOfRange OutOfRange { get => m_OutOfRange; set { m_OutOfRange = value; MarkDirty(); } }
|
||||
|
||||
// ── 外观 ──────────────────────────────────────────────────
|
||||
|
||||
private XChartLabelAnchor m_Anchor = XChartLabelAnchor.UpperCenter;
|
||||
/// <summary>标签矩形相对它那一点的位置(9 档)。<b>文字对齐由同一档算出来</b>,不另给一个字段</summary>
|
||||
public XChartLabelAnchor Anchor { get => m_Anchor; set { m_Anchor = value; MarkDirty(); } }
|
||||
|
||||
private Vector2 m_Offset = new Vector2(0f, 6f);
|
||||
/// <summary>从那个点再挪多少像素(非有限数按零算:NaN 进 anchoredPosition 会把这一件字整个挪出画面而不报错)</summary>
|
||||
public Vector2 Offset { get => m_Offset; set { m_Offset = value; MarkDirty(); } }
|
||||
|
||||
private int m_FontSize = 14;
|
||||
public int FontSize { get => m_FontSize; set { m_FontSize = Mathf.Max(1, value); MarkDirty(); } }
|
||||
|
||||
private Color m_LabelColor = Color.white;
|
||||
public Color LabelColor { get => m_LabelColor; set { m_LabelColor = value; MarkDirty(); } }
|
||||
|
||||
private float m_OutlineWidth;
|
||||
public float OutlineWidth { get => m_OutlineWidth; set { m_OutlineWidth = Mathf.Max(0f, value); MarkDirty(); } }
|
||||
|
||||
private Vector2 m_RectSize = new Vector2(160f, 30f);
|
||||
public Vector2 RectSize { get => m_RectSize; set { m_RectSize = new Vector2(Mathf.Max(0f, value.x), Mathf.Max(0f, value.y)); MarkDirty(); } }
|
||||
|
||||
private bool m_Wrap;
|
||||
public bool Wrap { get => m_Wrap; set { m_Wrap = value; MarkDirty(); } }
|
||||
|
||||
// ── 内部 ──────────────────────────────────────────────────
|
||||
|
||||
private bool m_GeometryDirty = true;
|
||||
private long m_LastDataVersion = -1;
|
||||
private int m_LastSpaceVersion = -1;
|
||||
private Matrix4x4 m_Composed = Matrix4x4.identity;
|
||||
|
||||
private int m_Records;
|
||||
private int m_Written;
|
||||
private int m_Cleared;
|
||||
private int m_Empty;
|
||||
private int m_Hidden;
|
||||
private int m_Skipped;
|
||||
|
||||
public override void MarkDirty() => m_GeometryDirty = true;
|
||||
|
||||
public override void OnRender()
|
||||
{
|
||||
base.OnRender();
|
||||
var space = Context?.Space;
|
||||
if (space == null) return;
|
||||
|
||||
var data = Data;
|
||||
bool spaceChanged = space.ProjectionVersion != m_LastSpaceVersion;
|
||||
bool dataChanged = data != null && data.Version != m_LastDataVersion;
|
||||
if (!m_GeometryDirty && !spaceChanged && !dataChanged) return;
|
||||
|
||||
if (spaceChanged || dataChanged) m_GeometryDirty = true;
|
||||
m_LastSpaceVersion = space.ProjectionVersion;
|
||||
m_LastDataVersion = data != null ? data.Version : -1;
|
||||
m_Composed = space.Compose(Transform);
|
||||
|
||||
if (data == null || !data.HasData)
|
||||
{
|
||||
m_Records = 0;
|
||||
RequestTextSlots(0);
|
||||
ClearTexts();
|
||||
m_GeometryDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int records = data.RecordCount;
|
||||
m_Records = records;
|
||||
RequestTextSlots(records);
|
||||
|
||||
double minX, maxX, minY, maxY, minZ, maxZ;
|
||||
ResolveRange(DimensionX, out minX, out maxX);
|
||||
ResolveRange(DimensionY, out minY, out maxY);
|
||||
ResolveRange(DimensionZ, out minZ, out maxZ);
|
||||
|
||||
var texts = Texts;
|
||||
m_Written = 0;
|
||||
m_Cleared = 0;
|
||||
m_Empty = 0;
|
||||
m_Hidden = 0;
|
||||
m_Skipped = 0;
|
||||
|
||||
for (int i = 0; i < records; i++)
|
||||
{
|
||||
bool ready = i < texts.Count && texts[i] != null;
|
||||
|
||||
string text;
|
||||
if (!data.TryGetLabelAt(i, LabelSlot, out text))
|
||||
{
|
||||
// 这一列没有这一格:数据不可用(不是"标签是空的")
|
||||
m_Skipped++;
|
||||
if (ready) BlankSlot(texts[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
// 那一格是空的(被清空过):这一件不画字,照实擦掉上一轮的字
|
||||
m_Empty++;
|
||||
if (ready) BlankSlot(texts[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
double x = data.GetValueAt(i, DimensionX);
|
||||
double y = data.GetValueAt(i, DimensionY);
|
||||
double z = data.GetValueAt(i, DimensionZ);
|
||||
|
||||
// 三个 out 先给初值:`&&` 短路时后面那两次调用根本没跑,编译器认不出"折得成就说明三个都赋过"
|
||||
// (散点那一处是 `if (!a || !b || !c) continue;` 的写法,所以它没这个问题)
|
||||
float fx = 0f, fy = 0f, fz = 0f;
|
||||
bool foldable = XChartCubeFoldMath.TryRatio01(x, minX, maxX, OutOfRange, out fx)
|
||||
&& XChartCubeFoldMath.TryRatio01(y, minY, maxY, OutOfRange, out fy)
|
||||
&& XChartCubeFoldMath.TryRatio01(z, minZ, maxZ, OutOfRange, out fz);
|
||||
|
||||
if (!foldable)
|
||||
{
|
||||
// 三个数都可用却被拒 ⇒ 是这一档主动不画;否则是坏数据(本来就不该画,另算)
|
||||
if (!IsBad(x) && !IsBad(y) && !IsBad(z)) m_Hidden++;
|
||||
else m_Skipped++;
|
||||
if (ready) BlankSlot(texts[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ready) continue; // 件还没到位:欠着件不算"这一行没标签"(pending= 那一行说的是它)
|
||||
|
||||
Vector2 local = space.Project(ChartToolSpace.NormalizedToCube(new Vector3(fx, fy, fz)), m_Composed)
|
||||
+ XChartLabelAnchorMath.SafeOffset(Offset);
|
||||
|
||||
WriteLabel(texts[i], local, text);
|
||||
m_Written++;
|
||||
}
|
||||
|
||||
// 槽位数比记录数多(上一轮表更长)时多出来的那些必须擦干净,否则上一轮的标签留在原地
|
||||
for (int i = records; i < texts.Count; i++)
|
||||
if (texts[i] != null) BlankSlot(texts[i]);
|
||||
|
||||
m_GeometryDirty = texts.Count < records;
|
||||
}
|
||||
|
||||
private void BlankSlot(TMP_Text slot)
|
||||
{
|
||||
slot.text = string.Empty;
|
||||
m_Cleared++;
|
||||
}
|
||||
|
||||
private void WriteLabel(TMP_Text label, Vector2 local, string text)
|
||||
{
|
||||
Vector2 anchor = XChartLabelAnchorMath.AnchorOf(Anchor);
|
||||
|
||||
label.text = text;
|
||||
label.fontSize = FontSize;
|
||||
label.color = LabelColor;
|
||||
label.enableWordWrapping = Wrap;
|
||||
label.outlineWidth = OutlineWidth;
|
||||
label.alignment = XChartLabelAnchorMath.AlignmentFor(Anchor);
|
||||
|
||||
var rect = label.rectTransform;
|
||||
rect.sizeDelta = RectSize;
|
||||
// 锚点写在 pivot 上:这样"那一格从点起排"和"点正好落在矩形的这一角"是同一件事。
|
||||
// anchorMin/Max 留在池的默认(中心),否则 anchoredPosition 的参照点会跟着换,
|
||||
// 同一个读数在两种锚法下答得不同。
|
||||
rect.pivot = anchor;
|
||||
rect.anchoredPosition = local;
|
||||
}
|
||||
|
||||
private void ClearTexts()
|
||||
{
|
||||
var texts = Texts;
|
||||
m_Cleared = 0;
|
||||
for (int i = 0; i < texts.Count; i++)
|
||||
if (texts[i] != null) BlankSlot(texts[i]);
|
||||
}
|
||||
|
||||
/// <summary>显示范围只问上下文要(覆盖优先、否则该维聚合):元素自己存一份范围就是"标签和轴对不上"的来路</summary>
|
||||
private void ResolveRange(int dimension, out double min, out double max)
|
||||
{
|
||||
var context = Context;
|
||||
if (context != null && context.TryResolveDomain(dimension, out min, out max)) return;
|
||||
min = 0.0;
|
||||
max = 1.0;
|
||||
}
|
||||
|
||||
private static bool IsBad(double value)
|
||||
=> double.IsNaN(value) || double.IsInfinity(value);
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
m_Records = 0;
|
||||
m_Written = 0;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 报表里这一行只印"这一帧到底有没有写、没写的话卡在哪":<b>数据侧</b>(skipped/hidden/empty)
|
||||
/// 与<b>槽位侧</b>(want/have/pending)必须分开,否则"这一行没标签"和"件还没发落"在画面上同形。
|
||||
/// </summary>
|
||||
internal override void AppendDebugLine(System.Text.StringBuilder sb)
|
||||
{
|
||||
base.AppendDebugLine(sb);
|
||||
sb.Append(" labelSlot=").Append(LabelSlot)
|
||||
.Append(" dim=").Append(DimensionX).Append('/').Append(DimensionY).Append('/').Append(DimensionZ)
|
||||
.Append(" records=").Append(m_Records)
|
||||
.Append(" want=").Append(RequestedTextCount)
|
||||
.Append(" have=").Append(Texts.Count)
|
||||
.Append(" pending=").Append(TextSlotsPending)
|
||||
.Append(" written=").Append(m_Written)
|
||||
.Append(" cleared=").Append(m_Cleared)
|
||||
.Append(" empty=").Append(m_Empty)
|
||||
.Append(" hidden=").Append(m_Hidden)
|
||||
.Append(" skipped=").Append(m_Skipped)
|
||||
.Append(" out=").Append(OutOfRange.ToString().ToLower())
|
||||
.Append(" anchor=").Append(Anchor.ToString().ToLower())
|
||||
.Append(" wrap=").Append(Wrap);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04e8bfc387c126047b089da0749b1cda
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericUI.XChart.Text
|
||||
{
|
||||
/// <summary>标签矩形相对它那一点的位置:9 档(四角 + 四边中点 + 中心)。</summary>
|
||||
public enum XChartLabelAnchor
|
||||
{
|
||||
LowerLeft,
|
||||
LowerCenter,
|
||||
LowerRight,
|
||||
MiddleLeft,
|
||||
Center,
|
||||
MiddleRight,
|
||||
UpperLeft,
|
||||
UpperCenter,
|
||||
UpperRight,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 锚点的<b>纯算</b>部分(离线可验)。
|
||||
///
|
||||
/// <para><b>为什么锚点与对齐必须出自同一张表</b>:锚定在左下角的矩形如果把字居中对齐,
|
||||
/// 字就横跨在那一点两侧,"标签贴在点上"这句话当场作废。以前这两件事各写各的
|
||||
/// (锚点一处、对齐来自池的默认值),所以改锚点而字仍居中是画面上最难归因的一种错。</para>
|
||||
/// </summary>
|
||||
public static class XChartLabelAnchorMath
|
||||
{
|
||||
/// <summary>九档锚点各自的那个位置([0,1] 内的矩形锚位)。九档互不相同是判据,不是巧合。</summary>
|
||||
public static Vector2 AnchorOf(XChartLabelAnchor anchor)
|
||||
{
|
||||
switch (anchor)
|
||||
{
|
||||
case XChartLabelAnchor.LowerLeft: return new Vector2(0f, 0f);
|
||||
case XChartLabelAnchor.LowerCenter: return new Vector2(0.5f, 0f);
|
||||
case XChartLabelAnchor.LowerRight: return new Vector2(1f, 0f);
|
||||
case XChartLabelAnchor.MiddleLeft: return new Vector2(0f, 0.5f);
|
||||
case XChartLabelAnchor.MiddleRight: return new Vector2(1f, 0.5f);
|
||||
case XChartLabelAnchor.UpperLeft: return new Vector2(0f, 1f);
|
||||
case XChartLabelAnchor.UpperCenter: return new Vector2(0.5f, 1f);
|
||||
case XChartLabelAnchor.UpperRight: return new Vector2(1f, 1f);
|
||||
default: return new Vector2(0.5f, 0.5f); // Center
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 这一档锚点对应的文字对齐:<b>由同一个锚点算出来</b>(横分量取锚点的 x、纵分量取锚点的 y)。
|
||||
/// 这样"贴在左下角"和"字从左下角起排"是同一件事,不再有第二处定义。
|
||||
/// </summary>
|
||||
public static TextAlignmentOptions AlignmentFor(XChartLabelAnchor anchor)
|
||||
{
|
||||
Vector2 a = AnchorOf(anchor);
|
||||
if (Mathf.Abs(a.x - 0.5f) < 1e-4f && Mathf.Abs(a.y - 0.5f) < 1e-4f) return TextAlignmentOptions.Center;
|
||||
if (Mathf.Abs(a.y - 0.5f) < 1e-4f) return a.x < 0.5f ? TextAlignmentOptions.MidlineLeft : TextAlignmentOptions.MidlineRight;
|
||||
if (Mathf.Abs(a.x - 0.5f) < 1e-4f) return a.y < 0.5f ? TextAlignmentOptions.Bottom : TextAlignmentOptions.Top;
|
||||
if (a.y < 0.5f) return a.x < 0.5f ? TextAlignmentOptions.BottomLeft : TextAlignmentOptions.BottomRight;
|
||||
return a.x < 0.5f ? TextAlignmentOptions.TopLeft : TextAlignmentOptions.TopRight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 偏移:<b>非有限数当成零</b>。NaN 进 anchoredPosition 会把这一件字整个挪出画面,
|
||||
/// 而且它不报错——这正是"计数全对、画面空无一物"那一族。
|
||||
/// </summary>
|
||||
public static Vector2 SafeOffset(Vector2 offset)
|
||||
{
|
||||
if (float.IsNaN(offset.x) || float.IsInfinity(offset.x)) offset.x = 0f;
|
||||
if (float.IsNaN(offset.y) || float.IsInfinity(offset.y)) offset.y = 0f;
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 887ef129beec6e841875636169cb0a4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XericUI.XChart.Space;
|
||||
|
||||
namespace XericUI.XChart.Text
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据标签元素的配置。<b>面板这一侧只存"选哪一档/哪一列"</b>:
|
||||
/// 锚点与文字对齐的对应关系住在 <see cref="XChartLabelAnchorMath"/>,
|
||||
/// 列号到标签槽的换算住在 <see cref="XChartColumnMath"/>——配置里再写一遍就会各说一套。
|
||||
///
|
||||
/// <para><c>LabelSlot</c> 是<b>标签列的序号</b>(不是数据表里的行号):窗口里排在最前面那些列就是标签列,
|
||||
/// 面板上看到的列号要换算成槽号才读得对,所以这一格存的是槽号而由同一处算出来。</para>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XChartElement("label", "标签", 60)]
|
||||
public sealed class XChartLabelConfig : XChartElementConfig
|
||||
{
|
||||
[Header("数据来源")]
|
||||
[SerializeField, Min(0), Tooltip("读第几个标签列(标签列在数据表里排在最前面;这一格是槽号,不是表里的行号)")]
|
||||
private int m_LabelSlot;
|
||||
|
||||
[SerializeField, Tooltip("标签挂在哪儿:三个数值维下标(显示范围在 chart 的数据板块逐维给)")]
|
||||
private int m_DimensionX;
|
||||
[SerializeField] private int m_DimensionY = 1;
|
||||
[SerializeField] private int m_DimensionZ = 2;
|
||||
|
||||
[SerializeField, Tooltip("标签自己的变换(叠在图的空间之上)")]
|
||||
private XChartToolTransform m_Transform = XChartToolTransform.Identity;
|
||||
|
||||
[SerializeField, Tooltip("数据落在显示范围之外时怎么办:原样画(默认)/ 夹到范围端点 / 整条隐藏")]
|
||||
private XChartValueOutOfRange m_OutOfRange = XChartValueOutOfRange.RenderAsIs;
|
||||
|
||||
[Header("呈现")]
|
||||
[SerializeField, Tooltip("标签矩形相对它那一点的位置(9 档)。文字对齐由同一档算出来,不另给一个字段")]
|
||||
private XChartLabelAnchor m_Anchor = XChartLabelAnchor.UpperCenter;
|
||||
|
||||
[SerializeField, Tooltip("从那个点再挪多少像素(非有限数按零算)")]
|
||||
private Vector2 m_Offset = new Vector2(0f, 6f);
|
||||
|
||||
[SerializeField, Min(1), Tooltip("字号")]
|
||||
private int m_FontSize = 14;
|
||||
|
||||
[SerializeField, Tooltip("字色")]
|
||||
private Color m_LabelColor = Color.white;
|
||||
|
||||
[SerializeField, Min(0f), Tooltip("描边宽度")]
|
||||
private float m_OutlineWidth;
|
||||
|
||||
[SerializeField, Tooltip("标签矩形大小(像素)。字超出的部分按下面的换行档处理")]
|
||||
private Vector2 m_RectSize = new Vector2(160f, 30f);
|
||||
|
||||
[SerializeField, Tooltip("字是否在这个矩形内换行")]
|
||||
private bool m_Wrap;
|
||||
|
||||
public override string ElementName => "Label";
|
||||
|
||||
public override XChartToolBase CreateTool() => new ChartToolLabels();
|
||||
|
||||
public override void ApplyTo(XChartToolBase tool)
|
||||
{
|
||||
if (!(tool is ChartToolLabels labels)) return;
|
||||
|
||||
labels.LabelSlot = m_LabelSlot;
|
||||
labels.DimensionX = m_DimensionX;
|
||||
labels.DimensionY = m_DimensionY;
|
||||
labels.DimensionZ = m_DimensionZ;
|
||||
labels.Transform = m_Transform;
|
||||
labels.OutOfRange = m_OutOfRange;
|
||||
|
||||
labels.Anchor = m_Anchor;
|
||||
labels.Offset = m_Offset;
|
||||
labels.FontSize = m_FontSize;
|
||||
labels.LabelColor = m_LabelColor;
|
||||
labels.OutlineWidth = m_OutlineWidth;
|
||||
labels.RectSize = m_RectSize;
|
||||
labels.Wrap = m_Wrap;
|
||||
|
||||
labels.MarkDirty();
|
||||
}
|
||||
|
||||
public override void CaptureFrom(XChartToolBase tool)
|
||||
{
|
||||
if (!(tool is ChartToolLabels labels)) return;
|
||||
|
||||
m_LabelSlot = labels.LabelSlot;
|
||||
m_Anchor = labels.Anchor;
|
||||
m_Offset = labels.Offset;
|
||||
m_FontSize = labels.FontSize;
|
||||
m_LabelColor = labels.LabelColor;
|
||||
m_RectSize = labels.RectSize;
|
||||
m_Wrap = labels.Wrap;
|
||||
}
|
||||
|
||||
public override int RequiredNumericDimensions => 3;
|
||||
|
||||
public override int RequiredRecordCount => 1;
|
||||
|
||||
public override int RequiredLabelColumns => 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3ac62f975d4c9f4180064e4839edabc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user