/// Credit drobina, w34edrtfg, playemgames /// Sourced from - http://forum.unity3d.com/threads/sprite-icons-with-text-e-g-emoticons.265927/ using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using UnityEngine.Events; using UnityEngine.EventSystems; namespace UnityEngine.UI.Extensions { // Image according to the label inside the name attribute to load, read from the Resources directory. The size of the image is controlled by the size property. // Use: [AddComponentMenu("UI/Extensions/TextPic")] [ExecuteInEditMode] // Needed for culling images that are not used // public class TextPic : Text, IPointerClickHandler, IPointerExitHandler, IPointerEnterHandler, ISelectHandler { /// /// Image Pool /// private readonly List m_ImagesPool = new List(); private readonly List culled_ImagesPool = new List(); private bool clearImages = false; private Object thisLock = new Object(); /// /// Vertex Index /// private readonly List m_ImagesVertexIndex = new List(); /// /// Regular expression to replace /// private static readonly Regex s_Regex = new Regex(@"", RegexOptions.Singleline); private string fixedString; public override void SetVerticesDirty() { base.SetVerticesDirty(); UpdateQuadImage(); } #if UNITY_EDITOR protected override void OnValidate() { base.OnValidate(); UpdateQuadImage(); } #endif /// /// After parsing the final text /// private string m_OutputText; [System.Serializable] public struct IconName { public string name; public Sprite sprite; } public IconName[] inspectorIconList; private Dictionary iconList = new Dictionary(); public float ImageScalingFactor = 1; // Write the name or hex value of the hyperlink color public string hyperlinkColor = "blue"; // Offset image by x, y [SerializeField] public Vector2 imageOffset = Vector2.zero; private Button button; //Commented out as private and not used.. Yet? //private bool selected = false; private List positions = new List(); /** * Little heck to support multiple hrefs with same name */ private string previousText = ""; public bool isCreating_m_HrefInfos = true; /** * Unity Inspector cant display Dictionary vars, * so we use this little hack to setup the iconList */ new void Start() { button = GetComponent