Rendering order under Canvas

Rendering order under Canvas

……

……

When playing games.

I found that under my Canvas, there are both static UI interface and dynamically created blood bar UI.

Then what.

I found that during the game, when the blood bar UI moved to overlap with the static UI, the static UI was covered.

Because the blood bar moves with the character, and not only the protagonist has the blood bar, but also the enemy has the blood bar. The effect I want is that the static UI can block the blood bar.

Originally, I thought about doing something complicated, such as creating two Canvas, but after some research, I found that the sub-items under the Canvas actually have a rendering order.

The Canvas canvas will render the bottom sub-items first, and then render them up one by one. Therefore, it is ok to put the position of the blood bar at the first position under the Canvas, and my needs can be met.

As follows

 

In the picture above, HP_Panel_max is an empty object. I will dynamically create a blood bar UI under this empty object, and this blood bar UI is rendered last, so when it overlaps, it will be blocked by all the UI below.

Guess you like

Origin blog.csdn.net/oyqho/article/details/129999790