- Home /
Unity Button Without an Image?
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).
Do you need to use the UI button? If just need to detect a click on the object, you could create a script and attach it. Here are a couple related answers...
Answer by VesuvianPrime · Dec 12, 2014 at 04:06 AM
As a workaround, can you use a transparent image?
Yes, this works. Feels pretty hacky though. Not sure about side-effects. Guessing there's no way to know if there's any runtime overhead for having a spriteless Image right?
I concur it's hacky, but it's not worth dwelling on if it keeps you moving with the rest of the game.
Anyone figure out how to do this without a blank image? I notice that the blank image is using a drawcall which I need to remove.
@Jinja Seconding Jinja's question, would love to get rid of the extra draw call created by the pure alpha image.
I managed to dodge a drawcall by using an image from the current atlas. Also, ins$$anonymous$$d of using NONE as the Source Image to draw a solid colour block, add a small white texture to the relevant atlas and use that ins$$anonymous$$d. NONE seems to add a extra draw call too. These are still hack solutions that shouldn't be required, but at least the extra draw calls can be dodged, even if the fill rate is still being wasted.
Answer by Neil-Kemojo-Martin · Oct 26, 2017 at 09:24 PM
This thread has an answer. Create a component that inherits Graphic, and use that instead of Image...
http://answers.unity3d.com/questions/1091618/ui-panel-without-image-component-as-raycast-target.html
Your answer
Follow this Question
Related Questions
Game not working on Tizen 0 Answers
How to play a Video IN a UI Button / as a Button? 0 Answers
How to use GUI Skin on button? 1 Answer
GUILayout.button hover texture not changing immediately 2 Answers
Inverted scrollrect 1 Answer