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

Keep a UI.Image from blocking Clicks?

Discussion in 'UGUI & TextMesh Pro' started by infinitypbr, Oct 9, 2014.

  1. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    I figure this has been asked before, but my googling has not found an answer. I have a border for a menu screen with a large transparent area in the middle. The border has elements that I want to show on top of the menu elements.

    However, the border -- being transparent even -- blocks any clicks on the menu.

    Is there a way to show the image on top without having it block any clicks? I see the "intractable" boolean for other UI elements, but not for UI.Image.

    Thanks!
     
  2. Chubzdoomer

    Chubzdoomer

    Joined:
    Sep 27, 2014
    Posts:
    106
    timyrlanforforum likes this.
  3. Chubzdoomer

    Chubzdoomer

    Joined:
    Sep 27, 2014
    Posts:
    106
    Update:
    I was just given the solution by one of Unity's developers.

    To keep any UI canvas or element from blocking clicks or registering mouse input, simply give that canvas or element a Canvas Group component (Add Component->Layout->Canvas Group), then turn off Blocks Raycasts.
     
  4. PeteD

    PeteD

    Joined:
    Jul 30, 2013
    Posts:
    71
    Cheers I have been having an issue with putting a little pointer image over a scrollview a and the whole scrollview suddenly became as dead as a certain salty sea.....
     
  5. take10animation

    take10animation

    Joined:
    Jun 19, 2011
    Posts:
    75
    Chubzdoomer post works. Thanks.
     
  6. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,078
    Guys, you can simply uncheck "Raycast Target" on any Graphic (which includes Image).
     
    IIoyd and LinghaoTech like this.
  7. mattpwibbu

    mattpwibbu

    Joined:
    Jan 16, 2019
    Posts:
    6
    This is what I tried initially, and it didn't work. In my case, I have a group of images in an empty container which follows the cursor within a given bounding RectTransform. I had all of those images with that "Raycast Target" toggle off, but they still blocked the mouse pointer raycasting and clicks...

    In my case, none of the mentioned solutions have worked yet. The objects that should be reacting to the mouse hover (buttons with Animation transitions) are not having their highlighted triggers updated. I have checked that these do work when the cursor follower is not underneath the cursor.
     
    anycolourulike likes this.
  8. mattpwibbu

    mattpwibbu

    Joined:
    Jan 16, 2019
    Posts:
    6
    After some digging, I discovered my issue. I was detecting when the mouse was inside of the given RectTransform using raycasting via the GraphicRaycaster. As the particular RectTransform in question was a border for a UI panel, underneath which my buttons were contained, the thing actually blocking the mouse raycasts was the UI panel border itself. I had to switch my method of detecting if the mouse position is inside of the panel from raycasting to using a method shown by @The_Mean_Fiddler in this post.

    Once the mouse position detection wasn't using raycasting anymore, everything worked great using just the Raycast Target property on each cursor follower image as @Hosnkobf mentioned. Thanks everyone!
     
  9. Codex_TRP

    Codex_TRP

    Joined:
    Sep 27, 2019
    Posts:
    1
    i know this is old post, but thank you very much u saved me
     
    BOBtastick12 likes this.