Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Manually adjust button interaction collider

Discussion in 'UGUI & TextMesh Pro' started by Paniku, Dec 15, 2014.

  1. Paniku

    Paniku

    Joined:
    Apr 11, 2013
    Posts:
    24
    The Button component seems to register mouse events from anything touching its image or any child images. I want to adjust its "interaction area" manually and not have it constructed automatically. Is there a way to do this?
     
  2. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    We use EmptyGraphic control that for that. Basically you use this component and use button script on same GO. This can go as child for GO in any size you want. Not sure about irregular shapes
    Code (CSharp):
    1. public class EmptyGraphic : Image
    2. {
    3.  
    4.     protected override void OnFillVBO(List<UIVertex> vbo)
    5.     {
    6.         vbo.Clear();
    7.         var item = default(UIVertex);
    8.         item.position = Vector3.one;
    9.         item.uv0 = Vector3.one;
    10.         vbo.Add(item);
    11.         vbo.Add(item);
    12.         vbo.Add(item);
    13.         vbo.Add(item);
    14.     }
    15. }
    16.  
    though.