Search Unity

How to customize Button collider's shape? How to create an Image without collider?

Discussion in 'UGUI & TextMesh Pro' started by Stephen-Zhou, Oct 6, 2014.

  1. Stephen-Zhou

    Stephen-Zhou

    Joined:
    Sep 23, 2013
    Posts:
    4
    In NGUI, a button has a collider and a UISprite separately, so that we can control the click range by customizing the collider shape. However in 4.6UI, the click range is bound to RectTransform's range, then the image. I wish to decouple them.
    Another problem. Images always have colliders that block click event. In NGUI, UISprite with no collider is "transparent" to click.
    They are the same wish, just decouple the graphic and the event!
     
  2. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Agreed, that would be a better system in my opinion.

    You can use an ICanvasRaycastFilter to filter the clicks however..
     
  3. Stephen-Zhou

    Stephen-Zhou

    Joined:
    Sep 23, 2013
    Posts:
    4
    I use CanvasGroup. That works. Thank you! However, CanvasGroup bring in extra draw calls.
    And how to use ICanvasRaycastFilter? Should I inherit it and override IsRaycastLocationValid()? That seems complicated.
     
  4. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Yep thats the way to do it apparently. I haven't tried it myself however!