'Unity GameObject rendering below GameObject lower in the hierarchy

I have a GameObject (TopSquare) that is rendered after PlayButton in the hierarchy, yet the PlayButton is showing on top. This goes against Unity's rule of objects added last are shown over objects added previously.

enter image description here

enter image description here

Why is this?



Solution 1:[1]

The square is a sprite that is an object in the World, while the button exists in the UI layer over it.

You have to use UI Image for black square instead of sprite renderer (Right-click on parent -> UI -> Image)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andriy Marshalek