update 0.5.7

This commit is contained in:
2026-05-27 12:08:28 +08:00
parent bccd5550d1
commit d3eb238bd6
23 changed files with 265 additions and 87 deletions
+21 -2
View File
@@ -2,7 +2,26 @@
## [Unrealse] ## [Unrealse]
添加一个方法,可以将任意数值转为分数形式。
## [0.5.7] 2026-05-27
添加:
* 一个数学方法 GetFraction,可以将任意数值转为分数形式。
* 语义化版本号 SemanticVersion,可以识别主流的版本号格式,并且符合判断规则。
* 添加基于字符串构建器的join方法。
* 添加了基于非平方根距离的快速判断扩展方法。
* 添加了关于RectTransform的快速尺寸设置方法。
* 联合对象池添加了对原件的标识。
* 添加纹理宏。
* 添加使用windows文件窗口的窗口调用函数(包含文件和目录访问)。
* 配置宏添加了获取方法。
* json序列化器添加了部分基础类型的null处理方案。
优化:
* TextBlockBuilder文本拼接逻辑,减少GC。
* 优化枚举库中的对比方法,改为了泛型模型,避免枚举装箱操作
修复:
* 对象池宏中联合对象池间接释放对象有可能报错导致无法释放的问题。
## [0.5.6] 2025-12-30 ## [0.5.6] 2025-12-30
@@ -94,7 +113,7 @@ UI库:
## [0.5.0] - 2025-07-04 ## [0.5.0] - 2025-07-04
中间那个版本感觉不吉利,所以没有,并不是缺少了这部分版本。我是坚定的唯物主义者这点并没有改变,我甚至在小区里买过44号车位(它确实要便宜一些),虽然后面长租给别人了。 我故意跳过了4.0版本,并不是缺少了这部分版本。
调整了插件编译结构 调整了插件编译结构
插件的部署地址换到了自己的[服务器](https://xeric.zicp.fun/). 插件的部署地址换到了自己的[服务器](https://xeric.zicp.fun/).
本体切换使用il2cpp版本的json dll,后面会将这部分内容放在dll外面,避免对某一特定版本dll依赖。 本体切换使用il2cpp版本的json dll,后面会将这部分内容放在dll外面,避免对某一特定版本dll依赖。
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: bcbfe98d29b703044a524e421fcacc2a guid: 114790f70dba8284a84b68083baa8418
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6116f350f3c2bca4dbb63afc5febe614 guid: e705db20b7214dc4cbfe3089b7219737
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
Binary file not shown.
+1 -37
View File
@@ -11,53 +11,17 @@ PluginImporter:
isExplicitlyReferenced: 0 isExplicitlyReferenced: 0
validateReferences: 1 validateReferences: 1
platformData: platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
- first: - first:
Any: Any:
second: second:
enabled: 1 enabled: 0
settings: {} settings: {}
- first: - first:
Editor: Editor Editor: Editor
second: second:
enabled: 1 enabled: 1
settings: settings:
CPU: AnyCPU
DefaultValueInitialized: true DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first: - first:
Windows Store Apps: WindowsStoreApps Windows Store Apps: WindowsStoreApps
second: second:
Binary file not shown.
+2 -2
View File
@@ -1,4 +1,4 @@
<h1 align="center">Xeric Library (WebGL)</h1> <h1 align="center">Xeric Library</h1>
<a href="https://xeric.zicp.fun/LiRuochen_WorkFlow/XericLibrary-Publish">个人发布页面(最新)</a> <a href="https://xeric.zicp.fun/LiRuochen_WorkFlow/XericLibrary-Publish">个人发布页面(最新)</a>
<a href="https://gitee.com/none_9_0/xeric-library2">Gitee发布页面</a> <a href="https://gitee.com/none_9_0/xeric-library2">Gitee发布页面</a>
@@ -22,7 +22,7 @@
欢迎使用Xeric Library, 这是一个专注代码的扩展库 欢迎使用Xeric Library, 这是一个专注代码的扩展库
* 专注Unity成员语法, 扩展多种基本类型的数据结构的Linq语法/语法糖, 提供: 函数平滑、 多项式计算、 权重拟合、 过程分级、 工业控制、 曲线绘制、 路径设置、 对象控制、 迭代扩展、 空间变换、 独特结构、 文本格式、 类型转换、 机器编码、 开发调试、 动态生成、 几何创建、 快速池化、 导航寻路、 隔离控制、 隔离输入、 语义化委托、 反射超驰、 数学常数、 单位换算、 排序算法、 程序调用、 网络连接等快捷用法。 * 专注Unity成员语法, 扩展多种基本类型的数据结构的Linq语法/语法糖, 提供: 函数平滑、 多项式计算、 权重拟合、 过程分级、 工业控制、 曲线绘制、 路径设置、 对象控制、 迭代扩展、 空间变换、 独特结构、 文本格式、 类型转换、 机器编码、 开发调试、 动态生成、 几何创建、 快速池化、 导航寻路、 隔离控制、 隔离输入、 语义化委托、 反射超驰、 数学常数、 单位换算、 排序算法、 程序调用、 网络连接、 windows窗口控制等快捷用法。
* 扩展特殊类型, 包括且不限于: 多维布尔、 样条曲线、 超级单例、 多例系统、 邻居网络、 四叉树、 字典树、 软引用封装器等。 * 扩展特殊类型, 包括且不限于: 多维布尔、 样条曲线、 超级单例、 多例系统、 邻居网络、 四叉树、 字典树、 软引用封装器等。
Binary file not shown.
Binary file not shown.
+134
View File
@@ -0,0 +1,134 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Deconstruction.Runtime
{
public static class XericSceneHelper
{
public delegate void SceneOperationAsyncDelegate(TimeSpan elapsedTime, float process, bool isDone);
/// <summary>
/// 获取索引对应的场景名称
/// </summary>
/// <param name="sceneBuildIndex"></param>
/// <returns></returns>
public static string GetSceneBuildIndexName(int sceneBuildIndex)
{
return IsSceneBuildIndexValid(sceneBuildIndex)
? SceneManager.GetSceneByBuildIndex(sceneBuildIndex).name
: string.Empty;
}
/// <summary>
/// 协程加载场景
/// </summary>
/// <param name="sceneName"></param>
/// <param name="loadProcess"></param>
/// <returns></returns>
public static IEnumerator LoadScene(string sceneName, SceneOperationAsyncDelegate loadProcess = null)
{
if (string.IsNullOrEmpty(sceneName))
{
Debug.LogError("加载场景的名称为空或无效,请检查后重试");
yield break;
}
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
yield return AsyncOperation(asyncLoad, loadProcess);
}
/// <summary>
/// 协程加载场景
/// </summary>
/// <param name="sceneBuildIndex"></param>
/// <param name="loadProcess"></param>
/// <returns></returns>
public static IEnumerator LoadScene(int sceneBuildIndex, SceneOperationAsyncDelegate loadProcess = null)
{
if (IsSceneBuildIndexValid(sceneBuildIndex))
{
Debug.LogError($"加载场景的索引({sceneBuildIndex})无效,请检查后重试");
yield break;
}
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(1, LoadSceneMode.Additive);
yield return AsyncOperation(asyncLoad, loadProcess);
}
/// <summary>
/// 协程卸载场景
/// </summary>
/// <param name="sceneName"></param>
/// <param name="loadProcess"></param>
/// <param name="froceUnloadUnusedAssets"></param>
/// <returns></returns>
public static IEnumerator UnloadSceneAsync(string sceneName, SceneOperationAsyncDelegate loadProcess = null, bool froceUnloadUnusedAssets = false)
{
if (string.IsNullOrEmpty(sceneName))
{
Debug.LogError("加载场景的名称为空或无效,请检查后重试");
yield break;
}
AsyncOperation asyncUnload = SceneManager.UnloadSceneAsync(sceneName);
yield return AsyncOperation(asyncUnload, loadProcess);
if (froceUnloadUnusedAssets)
UnloadUnusedAssets();
}
/// <summary>
/// 协程卸载场景
/// </summary>
/// <param name="sceneBuildIndex"></param>
/// <param name="loadProcess"></param>
/// <param name="froceUnloadUnusedAssets"></param>
/// <returns></returns>
public static IEnumerator UnloadSceneAsync(int sceneBuildIndex, SceneOperationAsyncDelegate loadProcess = null, bool froceUnloadUnusedAssets = false)
{
if (IsSceneBuildIndexValid(sceneBuildIndex))
{
Debug.LogError($"加载场景的索引({sceneBuildIndex})无效,请检查后重试");
yield break;
}
AsyncOperation asyncUnload = SceneManager.UnloadSceneAsync(sceneBuildIndex);
yield return AsyncOperation(asyncUnload, loadProcess);
if (froceUnloadUnusedAssets)
UnloadUnusedAssets();
}
private static IEnumerator AsyncOperation(AsyncOperation asyncOperator, SceneOperationAsyncDelegate loadProcess)
{
DateTime startTime = DateTime.Now;
do
{
loadProcess?.Invoke(DateTime.Now - startTime, asyncOperator.progress, false);
yield return null;
} while (!asyncOperator.isDone);
loadProcess?.Invoke(DateTime.Now - startTime, asyncOperator.progress, true);
}
/// <summary>
/// 设置为主场景
/// </summary>
/// <param name="sceneName"></param>
/// <returns></returns>
public static bool SetActiveScene(string sceneName)
{
if (string.IsNullOrEmpty(sceneName))
{
Debug.LogError("期望设置为主场景的名称为空或无效,请检查后重试");
return false;
}
var scene = SceneManager.GetSceneByName(sceneName);
return SceneManager.SetActiveScene(scene);
}
public static bool IsSceneBuildIndexValid(int sceneBuildIndex)
=> sceneBuildIndex < 0 || sceneBuildIndex > SceneManager.sceneCountInBuildSettings;
// 可选:强制进行垃圾回收,更彻底地释放内存
public static void UnloadUnusedAssets()
{
Resources.UnloadUnusedAssets();
System.GC.Collect();
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6dea79c8847b402ca99d1b51b3dd108d
timeCreated: 1776905969
Binary file not shown.
Binary file not shown.
+54 -5
View File
@@ -2,10 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
#if ODIN_INSPECTOR
using Sirenix.OdinInspector; using Sirenix.OdinInspector;
#endif
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
using UnityEngine.Pool;
using XericLibrary.Runtime.MacroLibrary; using XericLibrary.Runtime.MacroLibrary;
using XericLibrary.Runtime.Type; using XericLibrary.Runtime.Type;
@@ -14,6 +17,28 @@ namespace Deconstruction.UI.TmpText
/// <summary> /// <summary>
/// TMP超链接点击管理组件 /// TMP超链接点击管理组件
/// </summary> /// </summary>
/// <remarks>
/// 在tmp文本中使用id块创建超链接区域,鼠标点击后,该tmp文本会发出事件。
/// 超链接管理器可以快速管理这个事件,在事件根节点上挂载这个组件后,执行刷新操作将会自动绑定所有带有超链接的文本到此,然后由管理器发送统一的触发事件。
/// 超链接事件由id块的id决定,当用户触发超链接后,管理器上的 onClickLink 委托会被触发。
///
/// 当超链接管理器的层级下包含另一个超链接管理器时,默认不会触发这个管理器下的超链接。
/// 你可以在使用 GetChildrenTmpText2Hyperlink 追踪时手动设置 includeRepeatedMarking 为 ture 来强制包含。
/// GetChildrenTmpText2Hyperlink是主要的用来绑定所有文本到管理器的方法,如果你只是为了刷新文本,可以直接调用 RefreshHyperLink 。
///
/// 注意在使用Xchart,XchartUI等动态创建tmp文本组件的功能时,需要频繁进行刷新。
/// 特别是xchartui在刷新数据后,tmp文本会换成新的,这时必须重新刷新,否则表格中的超链接点击会没有反应。
///
/// 疑难解答:
/// * 文本超链接点击没有反应。
/// 首先检查格式是否为 <link=xxx></link> ,注意末尾一定要带上结束标记,不然tmp不识别。
/// 其次检查是否开启了射线检测,文本上方有没有其他也处于射线检测的对象遮挡。
/// 可以开启每个文本上的 自动解决射线检测问题 来解决。
///
/// * 文本没有被管理器识别。
/// 检查文本中是否带有<link=>的标记,只要有一个标记就会被识别为可能的链接,然后挂载超链接脚本。
/// 被挂载超链接脚本的文本后续无论如何都会被识别为超链接。
/// </remarks>
public class TMPHyperlinkManager : MonoBehaviour public class TMPHyperlinkManager : MonoBehaviour
{ {
/// <summary> /// <summary>
@@ -32,7 +57,16 @@ namespace Deconstruction.UI.TmpText
[SerializeField] [SerializeField]
public UnityEvent<string> onClickLink = new UnityEvent<string>(); public UnityEvent<string> onClickLink = new UnityEvent<string>();
/// <summary>
/// 当前超链接管理器下的所有超链接
/// </summary>
[ShowInInspector]
public List<TMPHyperlinkReceiver> Children { get; internal set; }
/// <summary>
/// 子项发生变更
/// </summary>
private bool _dirty;
/// <summary> /// <summary>
/// 当前摄像机 /// 当前摄像机
/// </summary> /// </summary>
@@ -66,6 +100,17 @@ namespace Deconstruction.UI.TmpText
_camera = canvas.worldCamera; _camera = canvas.worldCamera;
} }
protected void LateUpdate()
{
if (Children == null || Children.Count <= 0)
return;
for (int i = 0; i < Children.Count; i++)
{
if (Children[i].autoFixRayCastTargetState)
Children[i].SetRayCastVisible();
}
}
/// <summary> /// <summary>
/// 注册链接回调函数 /// 注册链接回调函数
/// </summary> /// </summary>
@@ -225,11 +270,11 @@ namespace Deconstruction.UI.TmpText
_tempGetChildrenTmpText2Hyperlink.Count > 0) _tempGetChildrenTmpText2Hyperlink.Count > 0)
return _tempGetChildrenTmpText2Hyperlink; return _tempGetChildrenTmpText2Hyperlink;
var children = includeRepeatedMarking var children = (includeRepeatedMarking
? transform.GetChildrenBFS() ? transform.GetChildrenBFS()
: transform.GetChildrenBFS<TMPHyperlinkManager>(); : transform.GetChildrenBFS<TMPHyperlinkManager>()).ToList();
var result = new List<TMPHyperlinkReceiver>(); var result = ListPool<TMPHyperlinkReceiver>.Get();
var hyperlinkType = typeof(TMPHyperlinkReceiver); var hyperlinkType = typeof(TMPHyperlinkReceiver);
var tmpTextType = typeof(TMP_Text); var tmpTextType = typeof(TMP_Text);
@@ -256,7 +301,11 @@ namespace Deconstruction.UI.TmpText
result.Add(child.gameObject.AddComponent<TMPHyperlinkReceiver>()); result.Add(child.gameObject.AddComponent<TMPHyperlinkReceiver>());
} }
} }
_dirty = true;
if (Children != null)
ListPool<TMPHyperlinkReceiver>.Release(Children);
Children = result;
return result; return result;
} }
+13 -1
View File
@@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
#if ODIN_INSPECTOR
using Sirenix.OdinInspector; using Sirenix.OdinInspector;
#endif
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
@@ -79,8 +81,18 @@ namespace Deconstruction.UI.TmpText
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
// xchart会自动设置射线不可见
if (autoFixRayCastTargetState) if (autoFixRayCastTargetState)
_tmpText.raycastTarget = true; SetRayCastVisible();
}
internal void SetRayCastVisible()
{
if (!_tmpText)
return;
if (_tmpText.raycastTarget)
return;
_tmpText.raycastTarget = true;
} }
public void OnPointerClick(PointerEventData eventData) public void OnPointerClick(PointerEventData eventData)
Binary file not shown.
Binary file not shown.
Binary file not shown.
+30 -32
View File
@@ -5796,6 +5796,36 @@
</summary> </summary>
<param name="message"></param> <param name="message"></param>
</member> </member>
<member name="T:XericLibrary.Runtime.MacroLibrary.MacroCecil">
<summary>
il指令分析库
</summary>
</member>
<member name="M:XericLibrary.Runtime.MacroLibrary.MacroCecil.GetAssemblyDefinition(System.Type)">
<summary>
从类上获取IL程序集
</summary>
<param name="type"></param>
<returns></returns>
</member>
<member name="M:XericLibrary.Runtime.MacroLibrary.MacroCecil.CallsBaseMethod(System.Type,System.String)">
<summary>
检查类上的方法是否调用了基类的类
</summary>
<param name="type"></param>
<param name="methodName"></param>
<returns></returns>
</member>
<member name="M:XericLibrary.Runtime.MacroLibrary.MacroCecil.CallsBaseMethod(System.String,System.String,System.String,System.String)">
<summary>
检查一个方法里是否通过base.调用基类的方法
</summary>
<param name="assemblyPath"></param>
<param name="typeName"></param>
<param name="methodName"></param>
<param name="baseMethodName"></param>
<returns></returns>
</member>
<member name="T:XericLibrary.Runtime.MacroLibrary.MacroMenu"> <member name="T:XericLibrary.Runtime.MacroLibrary.MacroMenu">
<summary> <summary>
菜单宏 菜单宏
@@ -10490,20 +10520,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:XericLibrary.Runtime.MacroLibrary.MacroObject.GetSceneComponentFirst``1">
<summary>
在场景中查找组件
</summary>
<typeparam name="T"></typeparam>
<returns></returns>
</member>
<member name="M:XericLibrary.Runtime.MacroLibrary.MacroObject.GetSceneComponentLast``1">
<summary>
在场景中查找组件
</summary>
<typeparam name="T"></typeparam>
<returns></returns>
</member>
<member name="M:XericLibrary.Runtime.MacroLibrary.MacroObject.GetAllSceneComponents``1"> <member name="M:XericLibrary.Runtime.MacroLibrary.MacroObject.GetAllSceneComponents``1">
<summary> <summary>
获取所有场景中的组件对象 获取所有场景中的组件对象
@@ -15771,15 +15787,6 @@
原生支持各种宏用法的mono脚本 原生支持各种宏用法的mono脚本
</summary> </summary>
</member> </member>
<member name="T:XericLibrary.Runtime.Type.Weakly.XericJumpWire`1">
<summary>
组件跳线
</summary>
<typeparam name="T"></typeparam>
<remarks>
跳线基于场景进行组件查找,并保存关联在该实例类中供后续成员快速查找。
</remarks>
</member>
<member name="T:XericLibrary.Runtime.Type.Weakly.XericSeriousMonoBehaviour"> <member name="T:XericLibrary.Runtime.Type.Weakly.XericSeriousMonoBehaviour">
<summary> <summary>
严格模式脚本 严格模式脚本
@@ -17018,15 +17025,6 @@
<param name="attributeName"></param> <param name="attributeName"></param>
<param name="hookPass"></param> <param name="hookPass"></param>
</member> </member>
<member name="T:XericLibrary.Runtime.Type.PreferredDerivedSingleMonoClassAttribute">
<summary>
单例首选派生类
</summary>
<remarks>
只在目标单例的类型不明确,泛型类型与单例模式不成封闭关系的时候,且这样的类型不止一个的时候。
使用这个特性标记实际需要实例化的类,在某些特殊的情况下,单例会自动根据特性进行生成。
</remarks>
</member>
<member name="T:XericLibrary.Runtime.Type.WeaklyHistoryMonoBase"> <member name="T:XericLibrary.Runtime.Type.WeaklyHistoryMonoBase">
<summary> <summary>
带有历史记录的脚本 带有历史记录的脚本
@@ -12,7 +12,6 @@ using Deconstruction.Manager;
using Deconstruction.Tool; using Deconstruction.Tool;
using Deconstruction.Type.Area; using Deconstruction.Type.Area;
using Deconstruction.Type.Serialize; using Deconstruction.Type.Serialize;
using Newtonsoft.Json;
using SerializerHelper.Type; using SerializerHelper.Type;
using UnityEngine.UI; using UnityEngine.UI;
using XericLibrary.Runtime.Debuger; using XericLibrary.Runtime.Debuger;
@@ -148,7 +147,7 @@ namespace SesothoLine
if (Input.GetKeyDown(KeyCode.S)) if (Input.GetKeyDown(KeyCode.S))
{ {
var obj = _wiresTool.ToolSerializeDispost(); var obj = _wiresTool.ToolSerializeDispost();
serializeContext = JsonConvert.SerializeObject(obj); serializeContext = MacroFile.JsonSerializerFormatter.formatter.Serializer(obj);
Debug.Log(obj.ToString()); Debug.Log(obj.ToString());
} }
if (Input.GetKeyDown(KeyCode.D)) if (Input.GetKeyDown(KeyCode.D))
@@ -159,7 +158,7 @@ namespace SesothoLine
return; return;
} }
var obj = JsonConvert.DeserializeObject<SerializeUnion>(serializeContext); var obj = MacroFile.JsonSerializerFormatter.formatter.Deserializer<SerializeUnion>(serializeContext);
_wiresTool.ToolDiserializDispost(obj); _wiresTool.ToolDiserializDispost(obj);
} }
+3 -3
View File
File diff suppressed because one or more lines are too long