B
B
Boris192018-02-02 09:23:54
Unity
Boris19, 2018-02-02 09:23:54

Do I need to make all the buttons on the stage as a GameObject?

I'm learning Unity, the following question arose - I want to make a button with a picture from a sprite. What is the best way to do this - just put the sprite on the canvas or make an empty object on the canvas, and add image in its properties? What will be the main difference? And if the object does not need to be created, then why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Basmanov, 2018-02-02
@Boris19

When you bring a sprite into the scene, an object is created with a SpriteRenderer component , whether you drag it onto the canvas or not doesn't matter. SpriteRenderer is not used inside ui, it has its own Image component . If you later want to turn this image into a button, you can use the Button component . Which particular path you choose to create the button does not affect the result, the only risk is that you forget to add some component and the button simply won't work. If you have not yet fully figured out how the ui works, then I advise you to use the submenuCreate > UI

A
Alex Maximovich, 2018-02-02
@flexer1992

Why not just use UI.Button ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question