udpate 0.6.6
This commit is contained in:
+42
-3
@@ -1,9 +1,48 @@
|
||||
# Changelog
|
||||
|
||||
## [Unrealse]
|
||||
## [0.6.6] 2026-11-03
|
||||
|
||||
* 添加win10+右下角消息框
|
||||
* 修复文件对话框中筛选器格式
|
||||
> 0.6.4 之后的内容分两段记:0.6.5 覆盖 2026-08-13 ~ 09-30(当时漏写,这里补上),
|
||||
> 本条覆盖 2026-10-15 之后。`Release/package.json` 从 0.6.4 直接到 0.6.6。
|
||||
|
||||
修复:
|
||||
* 切块后整条线不显示:子块是运行时新建的独立 Graphic,而 UGUI 的 `Graphic` 并不要求 `CanvasRenderer`,
|
||||
缺了它 `Graphic.Rebuild` 首句直接返回(静默不画、也不报错)。
|
||||
* 线段渲染器切块时中间块"有顶点没三角形":每段索引起点表在生成索引之后才扩容,中间块读出 0。
|
||||
* WebGL 构建下部分类型没有同步命名空间。
|
||||
|
||||
变更:
|
||||
* **UGUI 缓存渲染器切块**:曲线 / 线段 / 图元三类渲染器按顶点预算分块,避开单 Graphic 的 65535 顶点上限;
|
||||
块承接宿主材质与贴图,宿主停用时同步停画,运行时新建的块不写入场景/预制体。
|
||||
* 彻底完成 `Type` 命名空间移除:`XericLibrary.Type.*` 统一到 `XericLibrary.Runtime.*`
|
||||
(0.6.5 里已开始,这一版收口),升级后可能需要按编译错误补 `using`。
|
||||
|
||||
## [0.6.5] 2026-09-30
|
||||
|
||||
添加:
|
||||
* **界面样条与曲线进度条**:2D 矩形样条 / 3D 样条的编辑器交互 —— 端点增删(`+<| +< del >+ |>+`,删除按钮更窄且标红)、
|
||||
插入后自动选中并聚焦、逐点参数面板(颜色/位置/手柄/额外参数/缩放/旋转)、场景内悬停与点击拾取;
|
||||
增删/改参数/拖手柄五类操作全部进撤销栈。
|
||||
* `UISplineCurveRenderer`:按样条生成面片,`headTailPairs` 驱动多段头尾进度;弧长校正支持参数/烘焙两种映射,
|
||||
满轨 `{1,0}` 精确贴到曲线两端;烘焙可在"编辑停下/每次重建/手动"之间切换,采样细分等系数开放配置。
|
||||
* 新增 `GameObject/Xeric Library/Spline/` 菜单:2D Spline、3D Spline、Spline Curve Renderer、Progress Bar Demo。
|
||||
* **LitJson 定制版**(`Type/LitJson/`):NaN/±Infinity 双向读写、不可空值成员遇 null 回退 default、
|
||||
long→ulong 补齐、静态成员过滤;并与 MacroFile 统一成一条编解码链。
|
||||
* 菜单路径统一管理:新增 `MenuPath` 常量类与 `XericLibrary/Menu Path Audit` 巡检窗口,全部 `[MenuItem]` 收敛到常量。
|
||||
* 预编译宏支持 `[MacroDefine]` 特性动态注册。
|
||||
* 新增多精度旋钮结构 `FloatKnobPanel`(含编辑器绘制器)。
|
||||
* 纳入公有领域 `XericSimpleUILineRenderer`(含 Sample 场景与渐变贴图)。
|
||||
* XSSS 支持语法版本门控(`@Config:version`)、不透明多行值、全局样式表导出;Inspector 保存按最新语法版本写回。
|
||||
* 部分设置页迁到 `Project/Xeric Library/*` 与 `Preferences/Xeric Library/*`(含新增的宏定义设置页)。
|
||||
* win10+ 右下角消息框;补充文件对话框的筛选格式。
|
||||
|
||||
修复:
|
||||
* 进度条满轨不闭合:弧长重映射拿"采样点数"当分母(进度 1 落在 (N-1)/N);面片 uv 的分母与分子不同源,跨尾会回跳。
|
||||
* XSSS:0.1 多注解只摘最后一条导致注解丢进值里;解析时重复标记之间的内容被忽略。
|
||||
* TextBlock 界面树形图显示;蓝图网格材质与分析器 dll 重新生成。
|
||||
|
||||
变更:
|
||||
* 开始移除 `Type` 命名空间(`XericLibrary.Type.*` → `XericLibrary.Runtime.*`);构建/编译流程与 dll 支持调整。
|
||||
|
||||
## [0.6.4] 2026-08-10
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 114790f70dba8284a84b68083baa8418
|
||||
guid: bcbfe98d29b703044a524e421fcacc2a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
Binary file not shown.
@@ -30,6 +30,8 @@ Xeric Library 是一个专注代码的 Unity 扩展库。
|
||||
|
||||
**常用脚本**:游戏交互、界面适配、弱扩展、绘制工厂、SQL 扩展。
|
||||
|
||||
**界面与样条**:2D/3D 样条编辑(端点增删、逐点参数、场景内点选、整轮撤销)与样条驱动的 UI 曲线/进度条绘制。
|
||||
|
||||
**兼容不规范程序**:针对无设计规则的代码,提供基于反射、CIL 特性等底层语法的程序扩展:
|
||||
- **超级单例**:无需声明继承,径直调用即为单例。
|
||||
- **软接口 (SoftInterface)**:快速反射获取/设置,方法委托与字段属性一行调用。
|
||||
@@ -52,6 +54,15 @@ Xeric Library 是一个专注代码的 Unity 扩展库。
|
||||
|
||||
自研 Xeric Super Style Sheet (XSSS) 系统,使用 `.xsss` 自定义文本格式,类 CSS/USS 语法,专为 Unity 组件样式设计。基于字典树进行样式路径查找与匹配,支持命名空间隔离、动态监听热重载。提供完整的编辑器导入、Inspector 编辑及 PropertyDrawer 支持。
|
||||
|
||||
## 样条 (Spline)
|
||||
|
||||
2D 矩形样条(`XericRectSplinePath`)与 3D 样条(`XericSplinePath`)共用一套编辑器交互:端点增删、逐点参数编辑、
|
||||
场景内点选与悬停、按操作粒度进撤销栈。`UISplineCurveRenderer` 在此基础上按面片绘制 UI 曲线,
|
||||
`headTailPairs` 为每个面片提供一对头/尾进度,可直接驱动进度条;弧长校正可选参数映射或烘焙映射
|
||||
(烘焙时机可选"编辑停下 / 每次重建 / 手动")。
|
||||
|
||||
创建入口:`GameObject/Xeric Library/Spline/` 下的 2D Spline / 3D Spline / Spline Curve Renderer / Progress Bar Demo。
|
||||
|
||||
---
|
||||
|
||||
## 扩展库结构
|
||||
@@ -61,7 +72,8 @@ Xeric Library 是一个专注代码的 Unity 扩展库。
|
||||
| 模块 | 说明 |
|
||||
| --- | --- |
|
||||
| `MacroLibrary/` | 核心工具集,含 ~60 个分类宏文件,覆盖数学、几何、天文、排序、编码等 |
|
||||
| `Type/` | 特殊数据类型:四叉树/八叉树、字典树、多维布尔、软引用、卡尔曼滤波器等 |
|
||||
| `Type/` | 特殊数据类型:四叉树/八叉树、字典树、多维布尔、软引用、卡尔曼滤波器等(命名空间统一在 `XericLibrary.Runtime` 下) |
|
||||
| `Type/LitJson/` | 定制版 LitJson:NaN/±Infinity 双向读写、类型互转,MacroFile 的编解码链 |
|
||||
| `AI/Chat/` | DeepSeek AI 聊天接口封装 |
|
||||
| `PlayerController/` | 第一/三人称及上帝视角控制器 |
|
||||
| `SuperStyleSheet/` | XSSS 样式表运行时 |
|
||||
@@ -71,13 +83,18 @@ Xeric Library 是一个专注代码的 Unity 扩展库。
|
||||
| `XericComponent/` | 组件系统(样条曲线、网格布局、生命周期核心) |
|
||||
| `RegistrationActivation/` | 注册激活码校验(提供局域网授权分发功能,插件本身并无需要授权激活的功能) |
|
||||
|
||||
`Release/` 层是由 asmdef 直接编译的公开运行时,另有:`Runtime/Generation/` 下的 UGUI 曲线 / 线段 / 图元缓存渲染器
|
||||
(超限自动按顶点预算切块)、`Runtime/Generation/Curve/UISplineCurveRenderer.cs`(样条驱动的曲线与进度条)、
|
||||
`Runtime/UI/UILineRenderer/`(含 Sample 场景),以及 `Editor/` 下的样条创建菜单、渲染器 Inspector 等编辑器扩展。
|
||||
|
||||
---
|
||||
|
||||
## 编辑器界面
|
||||
|
||||
- **太阳系模拟界面**:注册激活窗口内嵌的日心说太阳系动画,在编辑器上也能看到漂亮的天体(地球、月球、大气等)。
|
||||
- **预编译宏管理**:`XericLibrary/Define Symbols/预设宏管理` 菜单入口,勾选框式增删编译标记。
|
||||
- **DeepSeek AI 对话**:编辑器内 AI 聊天窗口。
|
||||
- **预编译宏管理**:`XericLibrary/Precompiled Symbols Management` 菜单入口,勾选框式增删编译标记(设置页在 `Project/Xeric Library/Macro Defines`)。
|
||||
- **菜单路径巡检**:`XericLibrary/Menu Path Audit`,反射扫描已注册菜单,标红重复路径、标黄未收敛到 `MenuPath` 的手写字面量。
|
||||
- **DeepSeek AI 对话**:编辑器内 AI 聊天窗口(`XericLibrary/Xeric AI Chat`,偏好设置页 `Preferences/Xeric Library/AI Chat`)。
|
||||
- **生命周期性能分析**:`XLifeCycleProfile` 窗口,分析组件生命周期耗时。
|
||||
- **Hierarchy 面板定制**:增强的 Hierarchy 显示。
|
||||
- **颜色渐变编辑器**:线性颜色渐变编辑窗口。
|
||||
@@ -119,4 +136,5 @@ Xeric Library 是一个专注代码的 Unity 扩展库。
|
||||
## 注意事项
|
||||
|
||||
- 插件涉及多平台切换时,可能提供多种自动或手动切换方案,或默认使用 Windows 平台,请注意辨别。
|
||||
- 0.6.6 起数据类型的命名空间统一在 `XericLibrary.Runtime` 下(`XericLibrary.Type.*` 已移除),升级后可按编译错误补 `using`。
|
||||
- 如发现版本兼容性、计算错误、调用错误、使用问题,可通过发布页 Issues 或其他联系方式获得帮助。
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -61,6 +61,59 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
/// <summary>脏标记范围终点(曲线索引)</summary>
|
||||
protected int m_DirtyEndIndex = -1;
|
||||
|
||||
/// <summary>报表用:这一帧真正提交的顶点数(=缓存收缩后的大小,不是历史最高水位)</summary>
|
||||
public int LiveVertexCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每块顶点上限:UGUI 的 65535 是**每个 Graphic 各自**的上限,而这里是按数据条数长的
|
||||
/// (散点一个点一个图元 / 一条曲线一个条目)⇒ 必须按预算切块,否则条数一多就撞。
|
||||
/// </summary>
|
||||
public const int ChunkVertexBudget = 16000;
|
||||
|
||||
/// <summary>一块:只画条目 [FirstEntry, LastEntry),顶点数受预算约束</summary>
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
private sealed class CurveChunk : MaskableGraphic
|
||||
{
|
||||
public CurveCacheRendererBase Owner;
|
||||
public int FirstEntry;
|
||||
public int LastEntry;
|
||||
|
||||
/// <summary>贴图跟宿主走:宿主换进度贴图,块也得跟着换</summary>
|
||||
public override Texture mainTexture
|
||||
=> Owner != null ? Owner.mainTexture : base.mainTexture;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
raycastTarget = false;
|
||||
SyncOwnerVisual();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 块是**独立的 Graphic**:宿主身上的材质不会自动继承。
|
||||
/// 注意 Graphic.material 的 getter 在没有用户材质时返回的是 defaultMaterial,
|
||||
/// 所以这里读到/写下的都是“宿主实际会用的那一份”(曲线基类那份就是 XericUICurve)。
|
||||
/// </summary>
|
||||
public void SyncOwnerVisual()
|
||||
{
|
||||
if (Owner == null) return;
|
||||
if (material != Owner.material) material = Owner.material;
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
if (Owner != null) Owner.PopulateSlice(vh, FirstEntry, LastEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<CurveChunk> m_Chunks = new List<CurveChunk>();
|
||||
private int[] m_ChunkStarts = new int[8];
|
||||
|
||||
/// <summary>报表用:切了几块 / 最大的那块有多少顶点</summary>
|
||||
public int ChunkCount => m_Chunks.Count;
|
||||
public int MaxChunkVertices { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region API
|
||||
@@ -125,6 +178,7 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
m_MeshIndexCache.Clear();
|
||||
m_DirtyStartIndex = -1;
|
||||
m_DirtyEndIndex = -1;
|
||||
DisableChunks();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
@@ -209,6 +263,15 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
for (int i = 0; i < tempIndices.Count; i++)
|
||||
m_MeshIndexCache[preIndexCount + i] = tempIndices[i] + preVertexCount;
|
||||
|
||||
// 跟着当前内容**收缩**:缓存只增不减时,OnPopulateMesh 会把整个列表交给 VertexHelper,
|
||||
// 提交的顶点数就变成"历史最高水位"——一旦超过 UGUI 的 65535 就永久报错(数据降回来也不回落)。
|
||||
if (m_MeshVertexCache.Count > totalVertices)
|
||||
m_MeshVertexCache.RemoveRange(totalVertices, m_MeshVertexCache.Count - totalVertices);
|
||||
if (m_MeshIndexCache.Count > totalIndices)
|
||||
m_MeshIndexCache.RemoveRange(totalIndices, m_MeshIndexCache.Count - totalIndices);
|
||||
LiveVertexCount = totalVertices;
|
||||
RebuildChunks();
|
||||
|
||||
SetVerticesDirty();
|
||||
m_DirtyStartIndex = -1;
|
||||
m_DirtyEndIndex = -1;
|
||||
@@ -220,9 +283,133 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
// 本体不画:所有条目都交给受顶点预算约束的子块(每块一个 Graphic,各自远低于 65535)
|
||||
vh.Clear();
|
||||
if (m_MeshVertexCache.Count == 0 || m_MeshIndexCache.Count == 0) return;
|
||||
vh.AddUIVertexStream(m_MeshVertexCache, m_MeshIndexCache);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按顶点预算把条目切成若干块(顺序不变:块按提交顺序排、块内也按顺序,画家序不受影响)。
|
||||
/// </summary>
|
||||
private void RebuildChunks()
|
||||
{
|
||||
int count = m_Curves.Count;
|
||||
if (m_ChunkStarts.Length < count + 1) m_ChunkStarts = new int[count + 1];
|
||||
|
||||
int chunks = 0;
|
||||
int start = 0;
|
||||
int used = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int vertices = Mathf.Max(1, m_Curves[i].vertexCount);
|
||||
if (used > 0 && used + vertices > ChunkVertexBudget)
|
||||
{
|
||||
m_ChunkStarts[chunks++] = start;
|
||||
start = i;
|
||||
used = 0;
|
||||
}
|
||||
used += vertices;
|
||||
}
|
||||
if (count > 0) m_ChunkStarts[chunks++] = start;
|
||||
|
||||
MaxChunkVertices = 0;
|
||||
for (int c = 0; c < chunks; c++)
|
||||
{
|
||||
int end = (c + 1 < chunks) ? m_ChunkStarts[c + 1] : count;
|
||||
int sum = 0;
|
||||
for (int i = m_ChunkStarts[c]; i < end; i++) sum += Mathf.Max(1, m_Curves[i].vertexCount);
|
||||
if (sum > MaxChunkVertices) MaxChunkVertices = sum;
|
||||
}
|
||||
|
||||
EnsureChunkCount(chunks);
|
||||
for (int c = 0; c < chunks; c++)
|
||||
{
|
||||
m_Chunks[c].FirstEntry = m_ChunkStarts[c];
|
||||
m_Chunks[c].LastEntry = (c + 1 < chunks) ? m_ChunkStarts[c + 1] : count;
|
||||
m_Chunks[c].enabled = true;
|
||||
m_Chunks[c].SyncOwnerVisual();
|
||||
m_Chunks[c].SetVerticesDirty();
|
||||
}
|
||||
for (int c = chunks; c < m_Chunks.Count; c++) m_Chunks[c].enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓存被**块以外**的人改过之后调用(例如渲染器补写 uv0)。
|
||||
/// 只标脏宿主不够:几何现在长在子块上,宿主那份 VertexHelper 是空的。
|
||||
/// </summary>
|
||||
protected void MarkChunksDirty()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
if (m_Chunks[c] != null && m_Chunks[c].enabled) m_Chunks[c].SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureChunkCount(int count)
|
||||
{
|
||||
while (m_Chunks.Count < count)
|
||||
{
|
||||
// Graphic 的 CanvasRenderer 是**懒创建**的(只在属性被访问时补),而 UGUI 的 Graphic
|
||||
// 自己并不要求它 —— 三个基类都是显式贴了 RequireComponent 才有的。块这里直接建出来,
|
||||
// 不依赖"哪天 Rebuild 恰好被调到"(没有它 Rebuild 第一句就 return,静默不画)。
|
||||
var chunkGo = new GameObject("Chunk" + m_Chunks.Count,
|
||||
typeof(RectTransform), typeof(CanvasRenderer));
|
||||
// 先挂父级再 AddComponent:OnEnable 里的 CacheCanvas 与注册看的是**当时**的父级
|
||||
var rect = (RectTransform)chunkGo.transform;
|
||||
rect.SetParent(transform, false);
|
||||
rect.anchorMin = Vector2.zero;
|
||||
rect.anchorMax = Vector2.one;
|
||||
rect.offsetMin = Vector2.zero;
|
||||
rect.offsetMax = Vector2.zero;
|
||||
// 块是运行时建的,不标 DontSave 的话 Play 里存一下就会把它们写进场景/预制体
|
||||
chunkGo.hideFlags = HideFlags.DontSave;
|
||||
var chunk = chunkGo.AddComponent<CurveChunk>();
|
||||
chunk.Owner = this;
|
||||
chunk.raycastTarget = false;
|
||||
m_Chunks.Add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableChunks()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
if (m_Chunks[c] != null) m_Chunks[c].enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>把条目 [first, last) 的顶点与三角形写进这个块(索引按块内起点重基)</summary>
|
||||
internal void PopulateSlice(VertexHelper vh, int firstEntry, int lastEntry)
|
||||
{
|
||||
if (firstEntry < 0) firstEntry = 0;
|
||||
if (lastEntry > m_Curves.Count) lastEntry = m_Curves.Count;
|
||||
if (firstEntry >= lastEntry) return;
|
||||
|
||||
int vertexStart = 0;
|
||||
int indexStart = 0;
|
||||
for (int i = 0; i < firstEntry; i++)
|
||||
{
|
||||
vertexStart += m_Curves[i].vertexCount;
|
||||
indexStart += m_Curves[i].triangleCount * 3;
|
||||
}
|
||||
|
||||
int vertexEnd = vertexStart;
|
||||
int indexEnd = indexStart;
|
||||
for (int i = firstEntry; i < lastEntry; i++)
|
||||
{
|
||||
vertexEnd += m_Curves[i].vertexCount;
|
||||
indexEnd += m_Curves[i].triangleCount * 3;
|
||||
}
|
||||
|
||||
if (vertexEnd > m_MeshVertexCache.Count) vertexEnd = m_MeshVertexCache.Count;
|
||||
if (indexEnd > m_MeshIndexCache.Count) indexEnd = m_MeshIndexCache.Count;
|
||||
|
||||
for (int v = vertexStart; v < vertexEnd; v++) vh.AddVert(m_MeshVertexCache[v]);
|
||||
for (int i = indexStart; i + 2 < indexEnd; i += 3)
|
||||
{
|
||||
vh.AddTriangle(m_MeshIndexCache[i] - vertexStart,
|
||||
m_MeshIndexCache[i + 1] - vertexStart,
|
||||
m_MeshIndexCache[i + 2] - vertexStart);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -235,11 +422,39 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
RebuildAll();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
// 几何长在子块上,宿主关掉不等于它们停了:Graphic 停用只影响自己那份 VertexHelper
|
||||
DisableChunks();
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
DestroyChunks();
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 块是宿主运行时建的子物体:只删组件不删它们,会留下一堆孤儿块,
|
||||
/// 组件再挂回来时 EnsureChunkCount 又建一组同名的 ⇒ 两组块叠着画。
|
||||
/// </summary>
|
||||
private void DestroyChunks()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
var chunk = m_Chunks[c];
|
||||
if (chunk == null) continue;
|
||||
var chunkGo = chunk.gameObject;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) DestroyImmediate(chunkGo); else Destroy(chunkGo);
|
||||
#else
|
||||
Destroy(chunkGo);
|
||||
#endif
|
||||
}
|
||||
m_Chunks.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,6 +434,8 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
}
|
||||
|
||||
SetVerticesDirty();
|
||||
// 几何现在画在子块上:uv 是直接改缓存的,块不重取就还是改写前那一份
|
||||
MarkChunksDirty();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -63,6 +63,59 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
/// </summary>
|
||||
protected int m_DirtyEndSegment = -1;
|
||||
|
||||
/// <summary>报表用:这一帧真正提交的顶点数(=缓存收缩后的大小,不是历史最高水位)</summary>
|
||||
public int LiveVertexCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每块顶点上限:UGUI 的 65535 是**每个 Graphic 各自**的上限,线段数一多就要切块。
|
||||
/// 布局是均匀的(每段 VerticesPerSegment 个顶点),所以按段数切即可。
|
||||
/// </summary>
|
||||
public const int ChunkVertexBudget = 16000;
|
||||
|
||||
/// <summary>一块:只画段 [FirstSegment, LastSegment)</summary>
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
private sealed class LineChunk : MaskableGraphic
|
||||
{
|
||||
public CacheLineRendererBase Owner;
|
||||
public int FirstSegment;
|
||||
public int LastSegment;
|
||||
|
||||
/// <summary>贴图跟宿主走:宿主换贴图,块也得跟着换</summary>
|
||||
public override Texture mainTexture
|
||||
=> Owner != null ? Owner.mainTexture : base.mainTexture;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
raycastTarget = false;
|
||||
SyncOwnerVisual();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 块是**独立的 Graphic**:宿主身上的材质不会自动继承。
|
||||
/// 注意 Graphic.material 的 getter 在没有用户材质时返回的是 defaultMaterial,
|
||||
/// 所以这里读到/写下的都是“宿主实际会用的那一份”(曲线基类那份就是 XericUICurve)。
|
||||
/// </summary>
|
||||
public void SyncOwnerVisual()
|
||||
{
|
||||
if (Owner == null) return;
|
||||
if (material != Owner.material) material = Owner.material;
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
if (Owner != null) Owner.PopulateSlice(vh, FirstSegment, LastSegment);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<LineChunk> m_Chunks = new List<LineChunk>();
|
||||
private int[] m_SegmentIndexStart = new int[0];
|
||||
|
||||
/// <summary>报表用:切了几块 / 最大的那块有多少顶点</summary>
|
||||
public int ChunkCount => m_Chunks.Count;
|
||||
public int MaxChunkVertices { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用 Jobs 模式
|
||||
/// </summary>
|
||||
@@ -199,6 +252,7 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
m_MeshIndexCache.Clear();
|
||||
m_DirtyStartSegment = -1;
|
||||
m_DirtyEndSegment = -1;
|
||||
DisableChunks();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
@@ -267,6 +321,14 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
for (int i = 0; i < growBy; i++)
|
||||
m_MeshVertexCache.Add(new UIVertex());
|
||||
}
|
||||
else if (m_MeshVertexCache.Count > neededVertices)
|
||||
{
|
||||
// 缩小到当前真正需要的大小:缓存只增不减时,OnPopulateMesh 会把**整个列表**
|
||||
// 交给 VertexHelper,于是提交的顶点数是"历史最高水位"——一旦超过 UGUI 的 65535
|
||||
// 就永久报错(数据降下来也不回落)。必须每次推送都跟着当前内容收缩。
|
||||
m_MeshVertexCache.RemoveRange(neededVertices, m_MeshVertexCache.Count - neededVertices);
|
||||
}
|
||||
LiveVertexCount = neededVertices;
|
||||
|
||||
m_MeshIndexCache.Clear();
|
||||
|
||||
@@ -302,8 +364,16 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
}
|
||||
|
||||
// 5) 生成三角形索引
|
||||
// 每段索引的起点表要**先**扩容:写它的就是 GenerateIndicesForRange 里那趟循环,
|
||||
// 放到后面扩容等于"这一趟谁都写不进去",表里只剩末尾标记,
|
||||
// 非最末那几块就会读出 indexEnd=0 ⇒ 提交了顶点却一个三角形都没有(块在、线不见)。
|
||||
int recordedSegments = GetTotalSegmentCount();
|
||||
if (m_SegmentIndexStart.Length < recordedSegments + 1)
|
||||
m_SegmentIndexStart = new int[recordedSegments + 1];
|
||||
GenerateIndicesForRange(m_DirtyStartSegment, m_DirtyEndSegment,
|
||||
globalSegBase);
|
||||
m_SegmentIndexStart[recordedSegments] = m_MeshIndexCache.Count;
|
||||
RebuildChunks();
|
||||
|
||||
// 清除脏标记
|
||||
SetVerticesDirty();
|
||||
@@ -378,6 +448,8 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
for (int si = 0; si < subSegCount; si++)
|
||||
{
|
||||
// 子段 si == 0 是该条线的首段 → 无前驱同线段 → hasPrevInLine = false
|
||||
if (segIdx >= 0 && segIdx < m_SegmentIndexStart.Length)
|
||||
m_SegmentIndexStart[segIdx] = m_MeshIndexCache.Count;
|
||||
bool hasPrevInLine = (si > 0);
|
||||
LineMeshGenerator.GenerateSegmentIndices(segIdx, hasPrevInLine, m_MeshIndexCache);
|
||||
segIdx++;
|
||||
@@ -500,13 +572,102 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
// 本体不画:所有线段都交给受顶点预算约束的子块
|
||||
vh.Clear();
|
||||
}
|
||||
|
||||
if (m_MeshVertexCache.Count == 0 || m_MeshIndexCache.Count == 0)
|
||||
return;
|
||||
/// <summary>按顶点预算把段切成若干块(顺序不变,画家序不受影响)</summary>
|
||||
private void RebuildChunks()
|
||||
{
|
||||
int total = GetTotalSegmentCount();
|
||||
int perChunk = Mathf.Max(1, ChunkVertexBudget / LineMeshGenerator.VerticesPerSegment);
|
||||
int chunks = (total + perChunk - 1) / perChunk;
|
||||
|
||||
// 将缓存的顶点和索引写入 VertexHelper
|
||||
vh.AddUIVertexStream(m_MeshVertexCache, m_MeshIndexCache);
|
||||
EnsureChunkCount(chunks);
|
||||
MaxChunkVertices = 0;
|
||||
for (int c = 0; c < chunks; c++)
|
||||
{
|
||||
int first = c * perChunk;
|
||||
int last = Mathf.Min(total, first + perChunk);
|
||||
m_Chunks[c].FirstSegment = first;
|
||||
m_Chunks[c].LastSegment = last;
|
||||
m_Chunks[c].enabled = true;
|
||||
m_Chunks[c].SyncOwnerVisual();
|
||||
m_Chunks[c].SetVerticesDirty();
|
||||
int verts = (last - first) * LineMeshGenerator.VerticesPerSegment;
|
||||
if (verts > MaxChunkVertices) MaxChunkVertices = verts;
|
||||
}
|
||||
for (int c = chunks; c < m_Chunks.Count; c++) m_Chunks[c].enabled = false;
|
||||
}
|
||||
|
||||
private void EnsureChunkCount(int count)
|
||||
{
|
||||
while (m_Chunks.Count < count)
|
||||
{
|
||||
// Graphic 的 CanvasRenderer 是**懒创建**的(只在属性被访问时补),而 UGUI 的 Graphic
|
||||
// 自己并不要求它 —— 三个基类都是显式贴了 RequireComponent 才有的。块这里直接建出来,
|
||||
// 不依赖"哪天 Rebuild 恰好被调到"(没有它 Rebuild 第一句就 return,静默不画)。
|
||||
var chunkGo = new GameObject("LineChunk" + m_Chunks.Count,
|
||||
typeof(RectTransform), typeof(CanvasRenderer));
|
||||
// 先挂父级再 AddComponent:OnEnable 里的 CacheCanvas 与注册看的是**当时**的父级
|
||||
var rect = (RectTransform)chunkGo.transform;
|
||||
rect.SetParent(transform, false);
|
||||
rect.anchorMin = Vector2.zero;
|
||||
rect.anchorMax = Vector2.one;
|
||||
rect.offsetMin = Vector2.zero;
|
||||
rect.offsetMax = Vector2.zero;
|
||||
// 块是运行时建的,不标 DontSave 的话 Play 里存一下就会把它们写进场景/预制体
|
||||
chunkGo.hideFlags = HideFlags.DontSave;
|
||||
var chunk = chunkGo.AddComponent<LineChunk>();
|
||||
chunk.Owner = this;
|
||||
chunk.raycastTarget = false;
|
||||
m_Chunks.Add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableChunks()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
if (m_Chunks[c] != null) m_Chunks[c].enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 把段 [firstSegment, lastSegment) 的顶点与三角形写进这个块。
|
||||
/// 块首多带**前一段**的顶点:同一根线里子段的转角连接三角形会引用上一段的顶点,
|
||||
/// 不带就会在块的接缝处缺一个角。
|
||||
/// </summary>
|
||||
internal void PopulateSlice(VertexHelper vh, int firstSegment, int lastSegment)
|
||||
{
|
||||
int total = GetTotalSegmentCount();
|
||||
if (firstSegment < 0) firstSegment = 0;
|
||||
if (lastSegment > total) lastSegment = total;
|
||||
if (firstSegment >= lastSegment) return;
|
||||
|
||||
int perSeg = LineMeshGenerator.VerticesPerSegment;
|
||||
int vertexStart = Mathf.Max(0, firstSegment - 1) * perSeg;
|
||||
int vertexEnd = lastSegment * perSeg;
|
||||
if (vertexEnd > m_MeshVertexCache.Count) vertexEnd = m_MeshVertexCache.Count;
|
||||
if (vertexStart >= vertexEnd) return;
|
||||
|
||||
int indexStart = (firstSegment < m_SegmentIndexStart.Length)
|
||||
? m_SegmentIndexStart[firstSegment] : m_MeshIndexCache.Count;
|
||||
int indexEnd = (lastSegment < m_SegmentIndexStart.Length)
|
||||
? m_SegmentIndexStart[lastSegment] : m_MeshIndexCache.Count;
|
||||
if (indexEnd > m_MeshIndexCache.Count) indexEnd = m_MeshIndexCache.Count;
|
||||
|
||||
for (int v = vertexStart; v < vertexEnd; v++) vh.AddVert(m_MeshVertexCache[v]);
|
||||
for (int i = indexStart; i + 2 < indexEnd; i += 3)
|
||||
{
|
||||
int a = m_MeshIndexCache[i];
|
||||
int b = m_MeshIndexCache[i + 1];
|
||||
int d = m_MeshIndexCache[i + 2];
|
||||
if (a < vertexStart || a >= vertexEnd) continue;
|
||||
if (b < vertexStart || b >= vertexEnd) continue;
|
||||
if (d < vertexStart || d >= vertexEnd) continue;
|
||||
vh.AddTriangle(a - vertexStart, b - vertexStart, d - vertexStart);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -521,14 +682,37 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
// 几何长在子块上,宿主关掉不等于它们停了:Graphic 停用只影响自己那份 VertexHelper
|
||||
DisableChunks();
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
DestroyChunks();
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 块是宿主运行时建的子物体:只删组件不删它们,会留下一堆孤儿块,
|
||||
/// 组件再挂回来时 EnsureChunkCount 又建一组同名的 ⇒ 两组块叠着画。
|
||||
/// </summary>
|
||||
private void DestroyChunks()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
var chunk = m_Chunks[c];
|
||||
if (chunk == null) continue;
|
||||
var chunkGo = chunk.gameObject;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) DestroyImmediate(chunkGo); else Destroy(chunkGo);
|
||||
#else
|
||||
Destroy(chunkGo);
|
||||
#endif
|
||||
}
|
||||
m_Chunks.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,59 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
/// </summary>
|
||||
protected int m_DirtyEndIndex = -1;
|
||||
|
||||
/// <summary>报表用:这一帧真正提交的顶点数(=缓存收缩后的大小,不是历史最高水位)</summary>
|
||||
public int LiveVertexCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 每块顶点上限:UGUI 的 65535 是**每个 Graphic 各自**的上限,而图元是按数据条数长的
|
||||
/// (散点一个点一个图元)⇒ 必须按预算切块,否则条数一多就撞。
|
||||
/// </summary>
|
||||
public const int ChunkVertexBudget = 16000;
|
||||
|
||||
/// <summary>一块:只画图元 [FirstPrimitive, LastPrimitive),顶点数受预算约束</summary>
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
private sealed class PrimitiveChunk : MaskableGraphic
|
||||
{
|
||||
public PrimitiveCacheRendererBase Owner;
|
||||
public int FirstPrimitive;
|
||||
public int LastPrimitive;
|
||||
|
||||
/// <summary>贴图跟宿主走:宿主换贴图,块也得跟着换</summary>
|
||||
public override Texture mainTexture
|
||||
=> Owner != null ? Owner.mainTexture : base.mainTexture;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
raycastTarget = false;
|
||||
SyncOwnerVisual();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 块是**独立的 Graphic**:宿主身上的材质不会自动继承。
|
||||
/// 注意 Graphic.material 的 getter 在没有用户材质时返回的是 defaultMaterial,
|
||||
/// 所以这里读到/写下的都是“宿主实际会用的那一份”(曲线基类那份就是 XericUICurve)。
|
||||
/// </summary>
|
||||
public void SyncOwnerVisual()
|
||||
{
|
||||
if (Owner == null) return;
|
||||
if (material != Owner.material) material = Owner.material;
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
if (Owner != null) Owner.PopulateSlice(vh, FirstPrimitive, LastPrimitive);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<PrimitiveChunk> m_Chunks = new List<PrimitiveChunk>();
|
||||
private int[] m_ChunkStarts = new int[8];
|
||||
|
||||
/// <summary>报表用:切了几块 / 最大的那块有多少顶点</summary>
|
||||
public int ChunkCount => m_Chunks.Count;
|
||||
public int MaxChunkVertices { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region API
|
||||
@@ -109,6 +162,7 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
m_MeshIndexCache.Clear();
|
||||
m_DirtyStartIndex = -1;
|
||||
m_DirtyEndIndex = -1;
|
||||
DisableChunks();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
@@ -193,6 +247,15 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
for (int i = 0; i < tempIndices.Count; i++)
|
||||
m_MeshIndexCache[preIndexCount + i] = tempIndices[i] + preVertexCount;
|
||||
|
||||
// 跟着当前内容**收缩**:缓存只增不减时,OnPopulateMesh 会把整个列表交给 VertexHelper,
|
||||
// 提交的顶点数就变成"历史最高水位"——一旦超过 UGUI 的 65535 就永久报错(数据降回来也不回落)。
|
||||
if (m_MeshVertexCache.Count > totalVertices)
|
||||
m_MeshVertexCache.RemoveRange(totalVertices, m_MeshVertexCache.Count - totalVertices);
|
||||
if (m_MeshIndexCache.Count > totalIndices)
|
||||
m_MeshIndexCache.RemoveRange(totalIndices, m_MeshIndexCache.Count - totalIndices);
|
||||
LiveVertexCount = totalVertices;
|
||||
RebuildChunks();
|
||||
|
||||
SetVerticesDirty();
|
||||
m_DirtyStartIndex = -1;
|
||||
m_DirtyEndIndex = -1;
|
||||
@@ -204,9 +267,121 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
// 本体不画:所有图元都交给受顶点预算约束的子块(每块一个 Graphic,各自远低于 65535)
|
||||
vh.Clear();
|
||||
if (m_MeshVertexCache.Count == 0 || m_MeshIndexCache.Count == 0) return;
|
||||
vh.AddUIVertexStream(m_MeshVertexCache, m_MeshIndexCache);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按顶点预算把图元切成若干块(顺序不变:块按提交顺序排、块内也按顺序,画家序不受影响)。
|
||||
/// </summary>
|
||||
private void RebuildChunks()
|
||||
{
|
||||
int count = m_Primitives.Count;
|
||||
if (m_ChunkStarts.Length < count + 1) m_ChunkStarts = new int[count + 1];
|
||||
|
||||
int chunks = 0;
|
||||
int start = 0;
|
||||
int used = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int vertices = Mathf.Max(1, m_Primitives[i].vertexCount);
|
||||
if (used > 0 && used + vertices > ChunkVertexBudget)
|
||||
{
|
||||
m_ChunkStarts[chunks++] = start;
|
||||
start = i;
|
||||
used = 0;
|
||||
}
|
||||
used += vertices;
|
||||
}
|
||||
if (count > 0) m_ChunkStarts[chunks++] = start;
|
||||
|
||||
MaxChunkVertices = 0;
|
||||
for (int c = 0; c < chunks; c++)
|
||||
{
|
||||
int end = (c + 1 < chunks) ? m_ChunkStarts[c + 1] : count;
|
||||
int sum = 0;
|
||||
for (int i = m_ChunkStarts[c]; i < end; i++) sum += Mathf.Max(1, m_Primitives[i].vertexCount);
|
||||
if (sum > MaxChunkVertices) MaxChunkVertices = sum;
|
||||
}
|
||||
|
||||
EnsureChunkCount(chunks);
|
||||
for (int c = 0; c < chunks; c++)
|
||||
{
|
||||
m_Chunks[c].FirstPrimitive = m_ChunkStarts[c];
|
||||
m_Chunks[c].LastPrimitive = (c + 1 < chunks) ? m_ChunkStarts[c + 1] : count;
|
||||
m_Chunks[c].enabled = true;
|
||||
m_Chunks[c].SyncOwnerVisual();
|
||||
m_Chunks[c].SetVerticesDirty();
|
||||
}
|
||||
for (int c = chunks; c < m_Chunks.Count; c++) m_Chunks[c].enabled = false;
|
||||
}
|
||||
|
||||
private void EnsureChunkCount(int count)
|
||||
{
|
||||
while (m_Chunks.Count < count)
|
||||
{
|
||||
// Graphic 的 CanvasRenderer 是**懒创建**的(只在属性被访问时补),而 UGUI 的 Graphic
|
||||
// 自己并不要求它 —— 三个基类都是显式贴了 RequireComponent 才有的。块这里直接建出来,
|
||||
// 不依赖"哪天 Rebuild 恰好被调到"(没有它 Rebuild 第一句就 return,静默不画)。
|
||||
var chunkGo = new GameObject("PrimitiveChunk" + m_Chunks.Count,
|
||||
typeof(RectTransform), typeof(CanvasRenderer));
|
||||
// 先挂父级再 AddComponent:OnEnable 里的 CacheCanvas 与注册看的是**当时**的父级
|
||||
var rect = (RectTransform)chunkGo.transform;
|
||||
rect.SetParent(transform, false);
|
||||
rect.anchorMin = Vector2.zero;
|
||||
rect.anchorMax = Vector2.one;
|
||||
rect.offsetMin = Vector2.zero;
|
||||
rect.offsetMax = Vector2.zero;
|
||||
// 块是运行时建的,不标 DontSave 的话 Play 里存一下就会把它们写进场景/预制体
|
||||
chunkGo.hideFlags = HideFlags.DontSave;
|
||||
var chunk = chunkGo.AddComponent<PrimitiveChunk>();
|
||||
chunk.Owner = this;
|
||||
chunk.raycastTarget = false;
|
||||
m_Chunks.Add(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableChunks()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
if (m_Chunks[c] != null) m_Chunks[c].enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>把图元 [first, last) 的顶点与三角形写进这个块的 VertexHelper(索引按块内起点重基)</summary>
|
||||
internal void PopulateSlice(VertexHelper vh, int firstPrimitive, int lastPrimitive)
|
||||
{
|
||||
if (firstPrimitive < 0) firstPrimitive = 0;
|
||||
if (lastPrimitive > m_Primitives.Count) lastPrimitive = m_Primitives.Count;
|
||||
if (firstPrimitive >= lastPrimitive) return;
|
||||
|
||||
int vertexStart = 0;
|
||||
int indexStart = 0;
|
||||
for (int i = 0; i < firstPrimitive; i++)
|
||||
{
|
||||
vertexStart += m_Primitives[i].vertexCount;
|
||||
indexStart += m_Primitives[i].triangleCount * 3;
|
||||
}
|
||||
|
||||
int vertexEnd = vertexStart;
|
||||
int indexEnd = indexStart;
|
||||
for (int i = firstPrimitive; i < lastPrimitive; i++)
|
||||
{
|
||||
vertexEnd += m_Primitives[i].vertexCount;
|
||||
indexEnd += m_Primitives[i].triangleCount * 3;
|
||||
}
|
||||
|
||||
if (vertexEnd > m_MeshVertexCache.Count) vertexEnd = m_MeshVertexCache.Count;
|
||||
if (indexEnd > m_MeshIndexCache.Count) indexEnd = m_MeshIndexCache.Count;
|
||||
|
||||
for (int v = vertexStart; v < vertexEnd; v++) vh.AddVert(m_MeshVertexCache[v]);
|
||||
for (int i = indexStart; i + 2 < indexEnd; i += 3)
|
||||
{
|
||||
vh.AddTriangle(m_MeshIndexCache[i] - vertexStart,
|
||||
m_MeshIndexCache[i + 1] - vertexStart,
|
||||
m_MeshIndexCache[i + 2] - vertexStart);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -219,11 +394,39 @@ namespace XericLibrary.Runtime.UIGraph
|
||||
RebuildAll();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
// 几何长在子块上,宿主关掉不等于它们停了:Graphic 停用只影响自己那份 VertexHelper
|
||||
DisableChunks();
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
DestroyChunks();
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 块是宿主运行时建的子物体:只删组件不删它们,会留下一堆孤儿块,
|
||||
/// 组件再挂回来时 EnsureChunkCount 又建一组同名的 ⇒ 两组块叠着画。
|
||||
/// </summary>
|
||||
private void DestroyChunks()
|
||||
{
|
||||
for (int c = 0; c < m_Chunks.Count; c++)
|
||||
{
|
||||
var chunk = m_Chunks[c];
|
||||
if (chunk == null) continue;
|
||||
var chunkGo = chunk.gameObject;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) DestroyImmediate(chunkGo); else Destroy(chunkGo);
|
||||
#else
|
||||
Destroy(chunkGo);
|
||||
#endif
|
||||
}
|
||||
m_Chunks.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using XericLibrary.Runtime.MacroLibrary;
|
||||
using XericLibrary.Runtime.Type;
|
||||
using XericLibrary.Runtime.Type.Base;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -14,7 +14,7 @@ using Object = UnityEngine.Object;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace XericLibrary.Runtime.Type.Base
|
||||
namespace XericLibrary.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏对象与软引用 (gameobject with soft refrence)。
|
||||
|
||||
@@ -10,7 +10,6 @@ using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Pool;
|
||||
using XericLibrary.Runtime.MacroLibrary;
|
||||
using XericLibrary.Runtime.Type;
|
||||
|
||||
namespace Deconstruction.UI.TmpText
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+2002
-2763
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user