Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Disable Input events on Texts / Images?

Discussion in 'UGUI & TextMesh Pro' started by eppz, Mar 24, 2015.

  1. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
    I made a draggable panel implemented using IBeginDragHandler, IDragHandler, IEndDragHandler with some customization. Full implementation at https://github.com/eppz/Unity.Library.eppz_kit/blob/master/EPPZUI/EPPZUI_Draggable.cs

    Every Text / Image I put above this (or into) eats up all the pointer events. :(

    Is there any way to modify Text / Image components to tell them ignore pointer events, or at least not to Use() events, so they can propagate beneath. Something like text.selectable = false, or similar? I'd prefer a per object solution instead polling the raycaster all the time.
     
  2. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    The CanvasGroup component with Interactable/Blocks Raycasts disabled should be what you're looking for.
     
    eppz likes this.
  3. Feaver1968

    Feaver1968

    Joined:
    Nov 16, 2014
    Posts:
    70
    What happens if you don't call eventData.Use(); ?
     
  4. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
    Use() seemingly does nothing, I was intended to use this to prevent scene raycast hits behind the UI (but scene still reacts).
     
  5. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
    Thanks, seems I have to wrap up every "cold" component into a non-interactable CanvasGroup, gonna try it later on.

    Anyway, a similar checkbox on Text components would be the best. With CanvasGroups I have to split my UI hierarchy in unintended ways. An interactable Toggle will get too far from its label in the hierarchy this way... :/
     
  6. eppz

    eppz

    Joined:
    Aug 2, 2014
    Posts:
    172
    Works just fine, thanks.