ui基本完毕,修了一大把的bug
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class get_item_prefab : MonoBehaviour
|
||||
{
|
||||
private static readonly Regex RichTextTagRegex = new Regex("<.*?>", RegexOptions.Compiled);
|
||||
|
||||
[SerializeField] private bool testColorChange;
|
||||
[SerializeField] private Color defaultItemNameColor = Color.white;
|
||||
public Image item_btm;
|
||||
@@ -41,7 +44,14 @@ public class get_item_prefab : MonoBehaviour
|
||||
|
||||
if (itemName != null)
|
||||
{
|
||||
itemName.text = displayName ?? string.Empty;
|
||||
string resolvedName = displayName ?? string.Empty;
|
||||
itemName.supportRichText = testColorChange;
|
||||
if (!testColorChange)
|
||||
{
|
||||
resolvedName = StripRichTextTags(resolvedName);
|
||||
}
|
||||
|
||||
itemName.text = resolvedName;
|
||||
}
|
||||
|
||||
ApplyItemNameColor(testColorChange ? qualityColor : defaultItemNameColor);
|
||||
@@ -66,4 +76,14 @@ public class get_item_prefab : MonoBehaviour
|
||||
itemName.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
private static string StripRichTextTags(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return RichTextTagRegex.Replace(value, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user