Wesley Heron
Wesley Heron

Reputation: 423

How to Show UI Image Background (Canvas) in Front GameObject?

I' m new in Unity development, and I'm currently developing a memory card game, but I want to put a image background inside canvas where my grid buttons (this is like a card) are. But the image only stay in front buttons. And the buttons aren't show.

Upvotes: 0

Views: 4451

Answers (2)

Hellium
Hellium

Reputation: 7346

Official documentation of Unity :

Draw order of elements

UI elements in the Canvas are drawn in the same order they appear in the Hierarchy. The first child is drawn first, the second child next, and so on. If two UI elements overlap, the later one will appear on top of the earlier one.

To change which element appear on top of other elements, simply reorder the elements in the Hierarchy by dragging them. The order can also be controlled from scripting by using these methods on the Transform component: SetAsFirstSibling, SetAsLastSibling, and SetSiblingIndex.

Source : https://docs.unity3d.com/Manual/UICanvas.html

If you are working with Canvas set as "Screen Space", you can add a new canvas with your background and play with the renderOrder parameter : https://docs.unity3d.com/ScriptReference/Canvas-renderOrder.html

Upvotes: 1

SteelSoul
SteelSoul

Reputation: 141

Without knowing how you linked the button and the image gameobject together I'll guess based on the most common problem:

Either - in the hierarchy put the button under the image

Or - set the button as a child of the image gameobject

Upvotes: 0

Related Questions