Files
Cielonos/Assets/OtherPlugins/GraphicsCat/Modules/MarkupShaderGUI/Editor/Utils/GUIUtils.cs
SoulliesOfficial d15957c719 更新
2025-12-17 04:19:38 -05:00

42 lines
1.1 KiB
C#

#if UNITY_EDITOR
using UnityEngine;
namespace GraphicsCat.MarkupShaderGUIInternal
{
public class GUIUtils
{
static GUIContent s_TempContent = new GUIContent();
public static GUIContent TempContent(string displayName)
{
var guiContent = s_TempContent;
if (string.IsNullOrEmpty(displayName))
{
guiContent.text = "";
guiContent.tooltip = "";
return guiContent;
}
int start = displayName.IndexOf('[');
int end = displayName.IndexOf(']');
if (start >= 0 && end > start)
{
// Text is everything before '['
guiContent.text = displayName.Substring(0, start).Trim();
// Tooltip is inside [ ... ]
guiContent.tooltip = displayName.Substring(start + 1, end - start - 1).Trim();
}
else
{
// No brackets found ¡ú whole string is just text
guiContent.text = displayName.Trim();
}
return guiContent;
}
}
}
#endif