Will using many canvas and graphic raycaster components be a problem?

My game is a card game, instead of using sprites, it has lots of UI images. I have to assign the sorting layer and order of each UI elements, so I added a “Canvas” component to each of them and enables “Override Sorting”, then in order to drag/click on them, I added a “Graphic Raycaster” component to each of them.

This can solve my problem, but my concern is that will this use lots of resources and make it slow(it runs on mobile phones)?

The reason I have to assign the sorting layer is that for many of the UI elements, they have their own Particle effect. I have to put the Particle behind it and in front of other elements by adjusting the Particle’s Renderer Sorting Layer.

Thank you!

After some research, the answer is yes, it is a problem.

The reason is that for each canvas Unity will have to make new drawcalls. So if there’re too many canvases, it’ll be a problem.

On the other hand, because for every change of layout on a canvas Unity will recalculate everything on it, it’s not suggested to use a single big Canvas in a game (unless it’s very simple UI design).

For UI elements, you should divide them into different groups according how their layout changes during the game. For those that don’t change, put them into one canvas, and for some that changes frequently and together, put them into another canvas.