Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to create a button whose clickable area is only specified by a BoxCollider with Unity's new UI (similar to how you would do it from within NGUI). I can't get a Unity Button to work without the presence of an Image component (which ultimately represents the clickable area of the button).

enter image description here

share|improve this question

2 Answers 2

up vote 1 down vote accepted

There are two options for you.

1) Keep the image component on the button with a sprite, then set the transparency/alpha on the color to 0.

2) Write a separate script that you attach to a gameobject (Or image/button) that implements the Unity event interface: IPointerClickHandler and inherits from UIBehaviour. IPointerClickHandler is the interface Buttons use to register a mouse click.

share|improve this answer
    
The IPointerClickHandler is the way to go. Thanks :) The image with 0 alpha eats a draw call :( –  Blake Triana Aug 29 at 3:09

If I'm reading this correctly, I think all you need to do is remove the Sprite Renderer component(s) from the GameObject in question. Or -- what if you had a Sprite whose Alpha value was 0? Would that work?

share|improve this answer
    
Currently I'm just using an image component with "None" for the Sprite property. –  Blake Triana Dec 14 '14 at 4:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.