namespace textUtility { using System; using System.Collections; using System.Collections.Generic; using textUtility; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [Serializable] public class RichTextImage : Image, IPointerClickHandler { #region Config private bool EnableOverflowClick; [SerializeField] private Button Button; [SerializeField] private RichText RichText; private List SpriteMatches = new List(); private List UnderlineMatches = new List(); private List SuperlinkMatches = new List(); public RichTextImageManager ImageManager; private Dictionary> SuperlinkPositionsDictionary = new Dictionary>(); #endregion protected override void OnPopulateMesh(VertexHelper toFill) { //Debug.Log(1); toFill.Clear(); List baseMatches = new List(); baseMatches.AddRange(SpriteMatches); baseMatches.AddRange(UnderlineMatches); baseMatches.AddRange(SuperlinkMatches); //Debug.Log(baseMatches.Count); List triangles = new List(); List vertices = new List(); foreach (var baseMatch in baseMatches) { List> verticesList = GetRenderVerticesList(baseMatch); foreach (var tempVertices in verticesList) { triangles.AddRange(GetTriangles(vertices)); vertices.AddRange(tempVertices); } } //Debug.Log(vertices.Count); //Debug.Log(triangles.Count); toFill.AddUIVertexStream(vertices, triangles); } public void AddMatch(BaseMatch baseMatch) { if (baseMatch is SpriteMatch) { SpriteMatches.Add(baseMatch); sprite = Sprite.Create((baseMatch as SpriteMatch).SpriteInfo.Sprite.texture, new Rect(), new Vector2(0.5f, 0.5f)); } else if (baseMatch is UnderlineMatch) { UnderlineMatches.Add(baseMatch); } else if (baseMatch is SuperlinkMatch) { SuperlinkMatches.Add(baseMatch); if (EnableOverflowClick) { if (Button == null) { Button = gameObject.AddComponent