1using System.Collections;
2using System.Collections.Generic;
3using System.Text.RegularExpressions;
7[AddComponentMenu(
"UI/ToJ Effects/Character Spacing", 7)]
8[RequireComponent(typeof(Text))]
11 private const string REGEX_TAGS =
"<b>|</b>|<i>|</i>|<size=.*?>|</size>|<color=.*?>|</color>|<material=.*?>|</material>";
16 private List<UIVertex>
m_Verts =
new List<UIVertex>();
29 if (base.graphic !=
null)
31 base.graphic.SetVerticesDirty();
48 Text component = GetComponent<Text>();
49 List<string> list =
new List<string>();
50 for (
int i = 0; i < component.cachedTextGenerator.lineCount; i++)
52 int startCharIdx = component.cachedTextGenerator.lines[i].startCharIdx;
53 int num = ((i < component.cachedTextGenerator.lineCount - 1) ? component.cachedTextGenerator.lines[i + 1].startCharIdx : component.text.Length);
54 list.Add(component.text.Substring(startCharIdx, num - startCharIdx));
56 float num2 =
offset * (float)component.fontSize / 100f;
58 IEnumerator enumerator =
null;
60 if (component.alignment == TextAnchor.LowerLeft || component.alignment == TextAnchor.MiddleLeft || component.alignment == TextAnchor.UpperLeft)
64 else if (component.alignment == TextAnchor.LowerCenter || component.alignment == TextAnchor.MiddleCenter || component.alignment == TextAnchor.UpperCenter)
68 else if (component.alignment == TextAnchor.LowerRight || component.alignment == TextAnchor.MiddleRight || component.alignment == TextAnchor.UpperRight)
74 for (
int j = 0; j < list.Count; j++)
80 string text = list[j];
81 int lengthWithoutTags = text.Length;
82 if (lengthWithoutTags > component.cachedTextGenerator.characterCountVisible - num4)
84 lengthWithoutTags = component.cachedTextGenerator.characterCountVisible - num4;
85 text = text.Substring(0, lengthWithoutTags) +
" ";
88 if (component.supportRichText)
92 if (enumerator.MoveNext())
94 match = (Match)enumerator.Current;
97 bool flag2 = list[j].Length > 0 && (list[j][list[j].Length - 1] ==
' ' || list[j][list[j].Length - 1] ==
'\n');
98 float num5 = (float)(-(lengthWithoutTags - 1 - (flag2 ? 1 : 0))) * num2 * num3;
100 for (
int k = 0; k < text.Length; k++)
106 if (component.supportRichText && match !=
null && match.Index == k)
108 k += match.Length - 1;
109 num4 += match.Length - 1;
112 if (enumerator.MoveNext())
114 match = (Match)enumerator.Current;
117 if (num4 * 6 + 5 >=
m_Verts.Count)
122 for (
int l = 0; l < 6; l++)
124 UIVertex value =
m_Verts[num4 * 6 + l];
125 value.position += Vector3.right * (num2 * num6 + num5);
133 vh.AddUIVertexTriangleStream(
m_Verts);
138 MatchCollection matchCollection = Regex.Matches(text,
"<b>|</b>|<i>|</i>|<size=.*?>|</size>|<color=.*?>|</color>|<material=.*?>|</material>");
139 lengthWithoutTags = 0;
141 foreach (Match
item in matchCollection)
145 lengthWithoutTags = text.Length - num;
146 return matchCollection;
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
MatchCollection GetRegexMatchedTags(string text, out int lengthWithoutTags)
override void ModifyMesh(VertexHelper vh)