# Interacting with Sprite and UI Buttons in a Unity Game

DevFeed: [Interacting with Sprite and UI Buttons in a Unity Game](<https://devfeed.tech/articles/interacting-with-sprite-and-ui-buttons-in-a-unity-game-21806.md>)

Original publisher: [Read original article](<https://www.thepolyglotdeveloper.com/blog/2021/12/interacting-sprite-ui-buttons-unity-game/>)

Author: Nic Raboy

Published: 2022-01-01T00:57:42Z

Content type: tutorial

Language: en

Sources: [Nic Raboy](<https://devfeed.tech/sources/nic-raboy.md>)

Topics: [Unity](<https://devfeed.tech/topics/unity.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>)

Tags: [3d](<https://devfeed.tech/tags/3d.md>), [assets](<https://devfeed.tech/tags/assets.md>), [button](<https://devfeed.tech/tags/button.md>), [buttons](<https://devfeed.tech/tags/buttons.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [canvas](<https://devfeed.tech/tags/canvas.md>), [component](<https://devfeed.tech/tags/component.md>), [csharp](<https://devfeed.tech/tags/csharp.md>), [game](<https://devfeed.tech/tags/game.md>), [game-development](<https://devfeed.tech/tags/game-development.md>), [ide](<https://devfeed.tech/tags/ide.md>), [keyboard](<https://devfeed.tech/tags/keyboard.md>), [legacy](<https://devfeed.tech/tags/legacy.md>), [logs](<https://devfeed.tech/tags/logs.md>), [mouse](<https://devfeed.tech/tags/mouse.md>), [script](<https://devfeed.tech/tags/script.md>), [ui](<https://devfeed.tech/tags/ui.md>), [unity](<https://devfeed.tech/tags/unity.md>), [unity3d](<https://devfeed.tech/tags/unity3d.md>)

## AI overview

The excerpt presents two ways to add buttons in Unity. A sprite can serve as a button, but it needs a Box Collider 2D for clicks to trigger the attached script; the example reports a message in the logs. Alternatively, choosing GameObject -> UI -> Legacy -> Button creates a UI button inside a canvas and adds an event management system. The excerpt begins describing the script needed to power that UI button but cuts off before explaining its setup or behavior.

## Source excerpt

When you're developing a game, whether it be 2D or 3D, you're going to need to add menus with buttons at some point. These buttons could be as simple as a means to exit the game, or something more com... The post Interacting with Sprite and UI Buttons in a Unity Game appeared first on The Polyglot Developer.