TextPic.cs Added Fix for href tag, which was not working.
--HG-- branch : sushanta1991/textpiccs-was-not-working-for-href-unit-1474979920532release
parent
292fb39c93
commit
b75a03963e
|
@ -43,13 +43,13 @@ namespace UnityEngine.UI.Extensions
|
||||||
UpdateQuadImage();
|
UpdateQuadImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
protected override void OnValidate()
|
protected override void OnValidate()
|
||||||
{
|
{
|
||||||
base.OnValidate();
|
base.OnValidate();
|
||||||
UpdateQuadImage();
|
UpdateQuadImage();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// After parsing the final text
|
/// After parsing the final text
|
||||||
|
@ -101,12 +101,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
protected void UpdateQuadImage()
|
protected void UpdateQuadImage()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (UnityEditor.PrefabUtility.GetPrefabType(this) == UnityEditor.PrefabType.Prefab)
|
if (UnityEditor.PrefabUtility.GetPrefabType(this) == UnityEditor.PrefabType.Prefab)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
m_OutputText = GetOutputText();
|
m_OutputText = GetOutputText();
|
||||||
m_ImagesVertexIndex.Clear();
|
m_ImagesVertexIndex.Clear();
|
||||||
foreach (Match match in s_Regex.Matches(m_OutputText))
|
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));
|
hrefInfo.boxes.Add(new Rect(bounds.min, bounds.size));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UpdateQuadImage();
|
UpdateQuadImage();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -294,7 +290,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
protected string GetOutputText()
|
protected string GetOutputText()
|
||||||
{
|
{
|
||||||
s_TextBuilder.Length = 0;
|
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();
|
//m_HrefInfos.Clear();
|
||||||
var indexText = 0;
|
var indexText = 0;
|
||||||
fixedString = this.text;
|
fixedString = this.text;
|
||||||
|
@ -315,11 +310,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
var group = match.Groups[1];
|
var group = match.Groups[1];
|
||||||
int foundAtIndex = -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)) {
|
if(HrefInfosDoesExists(group.Value,out foundAtIndex)) {
|
||||||
m_HrefInfos[foundAtIndex].startIndex = s_TextBuilder.Length * 4; // Hyperlinks in text starting vertex indices;
|
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;
|
m_HrefInfos[foundAtIndex].endIndex = (s_TextBuilder.Length + match.Groups[2].Length - 1) * 4 + 3;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var hrefInfo = new HrefInfo
|
var hrefInfo = new HrefInfo
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue