我正在使用<link>帶有 TMP 的標簽在游戲中的某些文本中構建鏈接。這些鏈接包含一個 GUID,以便識別它所指向的內容。
<link=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>Some text</link>
這在我的大部分作業中都有效,但是當eGUID TMP 中的 a 在第一次出現時被切斷,例如,如果e在位置 10 TMP 僅設法回傳 GUID 中的前 10 個字符。
這就是發生的事情:
xxxxxxxx-xxex-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxx-xx
生成文本的方法
public string CharacterLink(CharacterInfo info)
{
return $"<color={characterColor.Format()}><link={info.Id}>{info.Fullname}</link></color>";
}
獲取鏈接的方法
public Entity GetLinkCharacter(TextMeshProUGUI text)
{
TMP_LinkInfo info = GetLink(text);
if (info.Equals(default(TMP_LinkInfo)))
{
return null;
}
return entities.GetEntity(Guid.Parse(info.GetLinkID()));
}
private TMP_LinkInfo GetLink(TextMeshProUGUI text)
{
int index = TMP_TextUtilities.FindIntersectingLink(text, Input.mousePosition, null);
if (index == -1)
{
return default;
}
return text.textInfo.linkInfo[index];
}
每當eGUID 中有一個e.
uj5u.com熱心網友回復:
缺少引號是問題所在。愚蠢的我忘了添加它們。
public string CharacterLink(CharacterInfo info)
{
return $"<color={characterColor.Format()}><link={info.Id}>{info.Fullname}</link></color>";
}
必須轉換成這個
public string CharacterLink(CharacterInfo info)
{
return $"<color=\"{characterColor.Format()}\"><link=\"{info.Id}\">{info.Fullname}</link></color>";
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/518181.html
標籤:C#。网unity3d
