Files
XericUIActionVessel/Runtime/Core/Vessel/XericUIExtendHelper.Text.cs
T
lrss3 49f616f4c7 添加unity容器类,允许使用泛型控制界面上的值。
目前添加了一次最多三个项目的属性。
2025-07-23 20:08:59 +08:00

43 lines
1.2 KiB
C#

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
}
}