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

Cal UI collider without corner space

Discussion in 'UGUI & TextMesh Pro' started by manlaikin1994, Jan 21, 2016.

  1. manlaikin1994

    manlaikin1994

    Joined:
    May 15, 2015
    Posts:
    179
    Screen Shot 2016-01-21 at 10.17.19 AM.png

    i want to ask is there anyway to make the actually collider in UGUI?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    By collider do you mean for clicking on or physics?
    As in you only want to detect a click when the mouse is over a pixel that does not have 0 alpha?
     
  3. manlaikin1994

    manlaikin1994

    Joined:
    May 15, 2015
    Posts:
    179
    yehyeh, i mean clicking.
    i only want to detect a click when the mouse is over a pixel that does not have 0 alpha
     
  4. manlaikin1994

    manlaikin1994

    Joined:
    May 15, 2015
    Posts:
    179
    i still cannot find solution from web, does anyone know?
     
  5. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    Create a class that derives from ICanvasRaycastFilter that queries the pixel under the pointer and returns false if its zero alpha. Add this component to any objects you want to use the filter with.
     
  7. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @karl.jones Thank you for this tip! I just wonder why this isn't implemented to button by default?
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    well its not nearly as efficient. All textures need to be set as readable for this to work. Add It as a feature request if you want it.

    You could also use the 2d physics system which is supported and more efficient than reading pixels but less accurate.
     
    eses likes this.