TextPic.cs Added Fix for href tag, which was not working.
--HG-- branch : sushanta1991/textpiccs-was-not-working-for-href-unit-1474979920532pull/413/head
parent
292fb39c93
commit
b75a03963e
|
@ -43,13 +43,13 @@ namespace UnityEngine.UI.Extensions
|
|||
UpdateQuadImage();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
UpdateQuadImage();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// After parsing the final text
|
||||
|
@ -101,12 +101,12 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
protected void UpdateQuadImage()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.PrefabUtility.GetPrefabType(this) == UnityEditor.PrefabType.Prefab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
m_OutputText = GetOutputText();
|
||||
m_ImagesVertexIndex.Clear();
|
||||
foreach (Match match in s_Regex.Matches(m_OutputText))
|
||||
|
@ -248,12 +248,8 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
hrefInfo.boxes.Add(new Rect(bounds.min, bounds.size));
|
||||
|
||||
}
|
||||
|
||||
|
||||
UpdateQuadImage();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -294,7 +290,6 @@ namespace UnityEngine.UI.Extensions
|
|||
protected string GetOutputText()
|
||||
{
|
||||
s_TextBuilder.Length = 0;
|
||||
// This also clears the list of boxes in m_HrefInfos created by OnPopulateMesh function, without boxes href wont work, so i commented this
|
||||
//m_HrefInfos.Clear();
|
||||
var indexText = 0;
|
||||
fixedString = this.text;
|
||||
|
@ -315,11 +310,10 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
var group = match.Groups[1];
|
||||
int foundAtIndex = -1;
|
||||
|
||||
// checking if m_HrefInfos element with same name already exists than just updating it with new values, instead of recreating it without bound data (which is important for href tag)
|
||||
if(HrefInfosDoesExists(group.Value,out foundAtIndex)) {
|
||||
m_HrefInfos[foundAtIndex].startIndex = s_TextBuilder.Length * 4; // Hyperlinks in text starting vertex indices;
|
||||
m_HrefInfos[foundAtIndex].endIndex = (s_TextBuilder.Length + match.Groups[2].Length - 1) * 4 + 3;
|
||||
|
||||
} else {
|
||||
var hrefInfo = new HrefInfo
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue