Search code examples
c#imageunity-game-enginetouchtoggle

How to touch toggle hidden under png image sprite in Unity3d


I have a scrollable set of toggles partially hidden under png image. The image serves as a "border" for the toggles. The problem is that if the image is in hierarchy on top of the toggle (what I want for composition reasons) the toggles stop to work. Is there a way to make image ignore touches and not prevent touches of toggles under it? I know that I can cut image into borders and get rid of the transparent hole but maybe there is simpler way?

Thank you


Solution

  • I typically solve this problem by adding a Canvas Group component to the transparent element.

    Canvas Group Documentation - http://docs.unity3d.com/Manual/class-CanvasGroup.html

    It has a property that allows you to set a UI Element to a "Non-Interactable" state, which will allow you to click / touch through it with your event system.

    enter image description here