添加unity容器类,允许使用泛型控制界面上的值。

目前添加了一次最多三个项目的属性。
This commit is contained in:
2025-07-23 20:08:59 +08:00
parent 84d79a430e
commit 49f616f4c7
63 changed files with 2580 additions and 6 deletions
@@ -0,0 +1,43 @@
using System;
using UnityEngine;
using XericUI.Core.Vessel;
#if dUI_TextMeshPro
using TMPro;
#endif
namespace XericUI.Core.Text
{
public static partial class XericUIExtendHelper
{
public static string DebugSelfName => "<TextMeshPro>";
#region TMP_Text
/// <summary>
/// 获取文本容器中的字符串内容
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string GetStringContext<T>(this ObjectVessel<T> obj)
where T : TMP_Text
=> obj != null ? obj.Target.text : string.Empty;
/// <summary>
/// 获取文本容器中的字符串内容
/// </summary>
/// <param name="obj"></param>
/// <param name="value"></param>
/// <returns></returns>
public static void SetStringContext<T>(this ObjectVessel<T> obj, string value)
where T : TMP_Text
{
if (obj != null)
obj.Target.text = value;
else
Debug.LogError($"正在向空{DebugSelfName}对象赋值");
}
#endregion
}
}