protected string GetOutputText() { if (this.s_TextBuilder == null) { this.s_TextBuilder = new StringBuilder(); } this.s_TextBuilder.Length = 0; this.m_HrefInfos.Clear(); int num = 0; int num2 = 0; foreach (Match match in this.s_HrefRegex.Matches(this.text)) { this.s_TextBuilder.Append(this.text.Substring(num, match.Index - num)); RichText.HrefInfo hrefInfo = new RichText.HrefInfo(); hrefInfo.startIndex = this.s_TextBuilder.Length * 4; hrefInfo.endIndex = (this.s_TextBuilder.Length + match.Groups[2].Length - 1) * 4 + 3; hrefInfo.name = match.Groups[1].Value; MatchCollection matchCollection = this.s_HrefColorReggex.Matches(match.Groups[2].Value); this.m_HrefInfos.Add(hrefInfo); this.s_TextBuilder.Append(match.Groups[2].Value); num = match.Index + match.Length; num2++; this.CreateUnderLine(num2, match.Groups[2].Value, matchCollection); } for (int i = num2 + 1; i <= this.m_TextUnderLinePool.Count; i++) { this.m_TextUnderLinePool[i - 1].gameObject.SetActive(false); } this.s_TextBuilder.Append(this.text.Substring(num, this.text.Length - num)); return(this.s_TextBuilder.ToString()); }
public void OnPointerClick(PointerEventData eventData) { Vector2 point; RectTransformUtility.ScreenPointToLocalPointInRectangle(base.rectTransform, eventData.position, eventData.pressEventCamera, out point); for (int i = 0; i < this.m_HrefInfos.Count; i++) { RichText.HrefInfo hrefInfo = this.m_HrefInfos[i]; List <Rect> boxes = hrefInfo.boxes; for (int j = 0; j < boxes.Count; j++) { if (boxes[j].Contains(point)) { if (this.m_OnHrefClick != null) { this.m_OnHrefClick.Call(new object[] { hrefInfo.name }); } return; } } } }
protected override void OnPopulateMesh(VertexHelper toFill) { if (string.IsNullOrEmpty(this.text) || this.text.Equals(string.Empty)) { return; } string text = this.orignText; this.orignText = this.m_Text; this.m_Text = this.m_OutputText; base.OnPopulateMesh(toFill); this.m_Text = this.orignText; UIVertex vertex = default(UIVertex); UIVertex uIVertex = default(UIVertex); for (int i = 0; i < this.m_ImagesVertexIndex.Count; i++) { int num = this.m_ImagesVertexIndex[i]; RectTransform rectTransform = this.m_ImagesPool[i].rectTransform; Vector2 sizeDelta = rectTransform.sizeDelta; if (num < toFill.currentVertCount) { toFill.PopulateUIVertex(ref vertex, num); float y = vertex.position.y; toFill.PopulateUIVertex(ref uIVertex, num - 1); toFill.PopulateUIVertex(ref vertex, this.m_ImagesFrontVertexIndex[i]); float d = (uIVertex.position.x + vertex.position.x) / 2f; rectTransform.anchoredPosition = Vector2.right * d + Vector2.up * (y + sizeDelta.y / 4f); toFill.PopulateUIVertex(ref vertex, num - 3); Vector3 position = vertex.position; int j = num; int num2 = num - 3; while (j > num2) { toFill.PopulateUIVertex(ref vertex, j); vertex.position = position; toFill.SetUIVertex(vertex, j); j--; } toFill.PopulateUIVertex(ref vertex, this.m_ImagesFrontVertexIndex[i] - 3); position = vertex.position; int k = this.m_ImagesFrontVertexIndex[i]; int num3 = this.m_ImagesFrontVertexIndex[i] - 3; while (k > num3) { toFill.PopulateUIVertex(ref vertex, k); vertex.position = position; toFill.SetUIVertex(vertex, k); k--; } } } int num4 = 0; for (int l = 0; l < this.m_HrefInfos.Count; l++) { RichText.HrefInfo hrefInfo = this.m_HrefInfos[l]; hrefInfo.boxes.Clear(); if (hrefInfo.startIndex < toFill.currentVertCount) { toFill.PopulateUIVertex(ref vertex, hrefInfo.startIndex); Vector3 position2 = vertex.position; Bounds bounds = new Bounds(position2, Vector3.zero); int m = hrefInfo.startIndex; int endIndex = hrefInfo.endIndex; while (m < endIndex) { if (m >= toFill.currentVertCount) { break; } toFill.PopulateUIVertex(ref vertex, m); position2 = vertex.position; if (position2.x < bounds.min.x) { hrefInfo.boxes.Add(new Rect(bounds.min, bounds.size)); bounds = new Bounds(position2, Vector3.zero); } else { bounds.Encapsulate(position2); } m++; } hrefInfo.boxes.Add(new Rect(bounds.min, bounds.size)); if (this.m_TextUnderLinePool[num4] != null) { RectTransform component = this.m_TextUnderLinePool[num4].GetComponent <RectTransform>(); toFill.PopulateUIVertex(ref vertex, hrefInfo.startIndex); component.anchoredPosition = new Vector2(vertex.position.x + component.sizeDelta.x / 2f, vertex.position.y - component.sizeDelta.y / 2f); } num4++; } } }