From 845f5d57009320b36b684679f53366205ce731c2 Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Sat, 8 Jul 2017 10:33:08 +0100 Subject: [PATCH] Updated TextPic. Recent Unity updates seem to have changed the Event System behaviour and all click events are broken when a TextPic is placed as the child of a button. (gave up figuring out why) Changed implementation, so that when TextPic is added as a child of a button, it adds a CanvasGroup and allows clicks to pass through it. Downside is that hyperlinks don't work. TextPic on buttons is purely decorative. The Button issue disables the ability to highlight links, so updated implementation to allow a "Selectable" component to be added to the TextPic to set highlight colours. Resolves #110 --- Scripts/Controls/TextPic.cs | 45 +++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/Scripts/Controls/TextPic.cs b/Scripts/Controls/TextPic.cs index 0164176..8763f68 100644 --- a/Scripts/Controls/TextPic.cs +++ b/Scripts/Controls/TextPic.cs @@ -25,6 +25,9 @@ namespace UnityEngine.UI.Extensions private bool clearImages = false; private Object thisLock = new Object(); + + + /// /// Vertex Index /// @@ -38,6 +41,16 @@ namespace UnityEngine.UI.Extensions private string fixedString; + [SerializeField] + [Tooltip("Allow click events to be received by parents, (default) blocks")] + private bool m_ClickParents; + + public bool AllowClickParents + { + get { return m_ClickParents; } + set { m_ClickParents = value; } + } + public override void SetVerticesDirty() { base.SetVerticesDirty(); @@ -77,6 +90,7 @@ namespace UnityEngine.UI.Extensions public Vector2 imageOffset = Vector2.zero; private Button button; + private Selectable highlightselectable; //Commented out as private and not used.. Yet? //private bool selected = false; @@ -95,7 +109,23 @@ namespace UnityEngine.UI.Extensions */ new void Start() { - button = GetComponent