XChart 图表框架落地(P0–P17):格线单一作者、面板一行状态、矢量场
此前整个 XChart 特性一直没有提交(分期 P0–P12 的代码与素材都还在工作区里)。这一批一并入库, 并含本轮 P13–P17 的改动(规范 Documentation/XChart-RenderFramework.md 新增 §22–§25): - P13:格线只剩一个作者——线框工具不再有"画格线 / 发布格线插槽"的代码路径;BG Cube Grid(原 MeshBg) 是唯一作者,且"画上去的线=发布给轴线的那份比例数组";插槽板新增 Unpublish(说得出"这里不再有线", 否则掩码筛掉的面会把上一轮的值留着被消费者吸走);渲染参数搬进元素表 (DeclareDefaultElements / AddDefaultElement + XChartElementTable 按类型去重,只在第一次读到表时补); 图上「立方体外观」那组字段删除、公共属性转发到元素表;面板逐行点名脚本注册的工具。 - P14 / P15:数据窗口文案收敛(行末 `-`、标题 `X [0]`、长说明退回 tooltip、范围页三行不再被压扁); 元素块收成一行状态 `▼ 名称 √ R… D… [↑][↓][-]`;**注册序由类型定死、只显示不给输入控件, 绘制序与元素在表里的位置绑定**(§24.5,他 2026-10-25 澄清);默认元素让删也让关; EnsureSpace 改成每次重建后都跑(删掉"空间"不再等于整张图空掉)。 - P17:矢量场——维数不够时不再静默不画(元素配置报需求,面板与报表同时印"需求/现有"); 相对/绝对两种读法收进纯算术 XChartVectorFieldMath;连续绘制(互斥显示把"相对/绝对"藏起来); 颜色维(色相走 0..256 色环,饱和/明度/不透明 0..1,不透明度不算硬需求);新增螺旋矢量场测试数据。 数据口径按他澄清修正为:前三维=坐标、一支箭头=相邻两条记录、第 4~7 维是颜色(§25、CHANGELOG 修正行)。 判据:编译门三臂 + 3 支对照绿;离线探针 436 项 0 失败;p4_control 55 支臂各红在自己点名的断言上; p2_control / pool_family / generator_gate / hierarchy_gate 在同一棵交付树上复跑。 (证据脚本与日志在包外的 .ximage-gate/,未入本仓库。)
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using XericUI.XChart;
|
||||
|
||||
namespace XericUI.XChart.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 元素类型登记表(编辑器专用)。
|
||||
///
|
||||
/// 反射扫描所有带 <see cref="XChartElementAttribute"/> 的 <see cref="XChartElementConfig"/> 派生类,
|
||||
/// 供 Inspector 的"添加元素"菜单列出。放在编辑器程序集里是刻意的:运行时不需要枚举全程序集,
|
||||
/// 也避免 IL2CPP 裁剪把只在菜单里用到的类型剪掉。
|
||||
/// </summary>
|
||||
internal static class XChartElementRegistry
|
||||
{
|
||||
internal struct Entry
|
||||
{
|
||||
public Type ConfigType;
|
||||
public XChartElementAttribute Meta;
|
||||
}
|
||||
|
||||
private static List<Entry> s_Entries;
|
||||
|
||||
/// <summary>所有已注册元素(按菜单序)</summary>
|
||||
internal static IReadOnlyList<Entry> GetEntries()
|
||||
{
|
||||
if (s_Entries != null) return s_Entries;
|
||||
|
||||
s_Entries = new List<Entry>();
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
for (int a = 0; a < assemblies.Length; a++)
|
||||
{
|
||||
Type[] types;
|
||||
try
|
||||
{
|
||||
types = assemblies[a].GetTypes();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// 动态程序集/加载失败的程序集直接跳过,不能让一个坏程序集挡住菜单
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < types.Length; i++)
|
||||
{
|
||||
var type = types[i];
|
||||
if (type == null || type.IsAbstract || !typeof(XChartElementConfig).IsAssignableFrom(type))
|
||||
continue;
|
||||
|
||||
var meta = (XChartElementAttribute)Attribute.GetCustomAttribute(
|
||||
type, typeof(XChartElementAttribute), false);
|
||||
if (meta == null) continue;
|
||||
|
||||
s_Entries.Add(new Entry { ConfigType = type, Meta = meta });
|
||||
}
|
||||
}
|
||||
|
||||
s_Entries.Sort((x, y) =>
|
||||
{
|
||||
int byOrder = x.Meta.MenuOrder.CompareTo(y.Meta.MenuOrder);
|
||||
return byOrder != 0 ? byOrder : string.CompareOrdinal(x.Meta.DisplayName, y.Meta.DisplayName);
|
||||
});
|
||||
return s_Entries;
|
||||
}
|
||||
|
||||
/// <summary>按类型造一个默认配置</summary>
|
||||
internal static XChartElementConfig Create(Type configType)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (XChartElementConfig)Activator.CreateInstance(configType);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogError("Failed to create a chart element config: " + configType + " / " + exception.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user