diff --git a/Scripts/Controls/TextPic.cs b/Scripts/Controls/TextPic.cs index f03cf3f..641b8a0 100644 --- a/Scripts/Controls/TextPic.cs +++ b/Scripts/Controls/TextPic.cs @@ -10,421 +10,456 @@ 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; + // 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")] - /// - /// Vertex Index - /// - private readonly List m_ImagesVertexIndex = new List(); + [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; - /// - /// Regular expression to replace - /// - private static readonly Regex s_Regex = - new Regex(@"", RegexOptions.Singleline); + /// + /// Vertex Index + /// + private readonly List m_ImagesVertexIndex = new List(); - private string fixedString; + /// + /// Regular expression to replace + /// + private static readonly Regex s_Regex = + new Regex(@"", RegexOptions.Singleline); - public override void SetVerticesDirty() - { - base.SetVerticesDirty(); - UpdateQuadImage(); - } + private string fixedString; -#if UNITY_EDITOR - protected override void OnValidate() - { - base.OnValidate(); - UpdateQuadImage(); - } -#endif + public override void SetVerticesDirty() + { + base.SetVerticesDirty(); + UpdateQuadImage(); + } - /// - /// After parsing the final text - /// - private string m_OutputText; + #if UNITY_EDITOR + protected override void OnValidate() + { + base.OnValidate(); + UpdateQuadImage(); + } + #endif - [System.Serializable] - public struct IconName - { - public string name; - public Sprite sprite; - } - public IconName[] inspectorIconList; + /// + /// After parsing the final text + /// + private string m_OutputText; - private Dictionary iconList = new Dictionary(); + [System.Serializable] + public struct IconName + { + public string name; + public Sprite sprite; + } + public IconName[] inspectorIconList; - public float ImageScalingFactor = 1; + private Dictionary iconList = new Dictionary(); - // Write the name or hex value of the hyperlink color - public string hyperlinkColor = "blue"; + public float ImageScalingFactor = 1; - // Offset image by x, y - [SerializeField] - public Vector2 imageOffset = Vector2.zero; + // Write the name or hex value of the hyperlink color + public string hyperlinkColor = "blue"; - private Button button; + // Offset image by x, y + [SerializeField] + public Vector2 imageOffset = Vector2.zero; - //Commented out as private and not used.. Yet? - //private bool selected = false; + private Button button; - private List positions = new List(); + //Commented out as private and not used.. Yet? + //private bool selected = false; - /** + private List positions = new List(); + + /** * Unity Inspector cant display Dictionary vars, * so we use this little hack to setup the iconList */ - new void Start() - { - button = GetComponent