1.在其他博主的基础上,增加了图片可以点击的功能,因为我临时遇到了这个需求,这应该是图文混排的终极版本了吧,如果以后图文混排相关功能还有增加的话,我再临时更新此篇文章吧!希望可以帮到拥有同样需求的你们,谢谢!
2.此代码为图文混排代码
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
/// <summary>
/// 文本控件,支持超链接、图片
/// </summary>
[AddComponentMenu("UI/LinkImageText", 10)]
public class LinkImageText : RichText, IPointerClickHandler
{
/// <summary>
/// 解析完最终的文本
/// </summary>
private string m_OutputText;
/// <summary>
/// 图片池
/// </summary>
protected readonly List<Image> m_ImagesPool = new List<Image>();
/// <summary>
/// 图片的最后一个顶点的索引
/// </summary>
private readonly List<int> m_ImagesVertexIndex = new List<int>();
/// <summary>
/// 超链接信息列表
/// </summary>
private readonly List<HrefInfo> m_HrefInfos = new List<HrefInfo>();
/// <summary>
/// 图片信息列表
/// </summary>
private readonly List<ImageInfo> m_ImageInfos = new List<ImageInfo>();
/// <summary>
/// 文本构造器
/// </summary>
protected static readonly StringBuilder s_TextBuilder = new StringBuilder();
[Serializable]
public class HrefClickEvent : UnityEvent<string> { }
[SerializeField]
private HrefClickEvent m_OnHrefClick = new HrefClickEvent();
/// <summary>
/// 超链接点击事件
/// </summary>
public HrefClickEvent onHrefClick
{
get { return