Original Question: I’d like to know if a button that uses Sprite Swap, will mark the canvas as dirty when the user hovers the mouse over the button?
*Edit for clarity:
When certain parameters change in a canvas, it causes Unity to “rebuild” the mesh via Canvas.buildBatch. This is cpu intensive and can cause spikes/hiccups.
This article mentions only Transform changes as a cause of a rebuild:
The article goes so far as saying that changing text does NOT involve a batch build. My question seeks certainty regarding other types of changes such as a button sprite-swap on hover or the tint effect on hover. (Assume there are NO animations)
anything that changes the canvas will force a canvas repaint, not only images, scroll bars buttons animations, anything. thats why you should separate canvas depending on when their objects get dirty, if you have a button that is animated, it should go in a separate canvas from the static buttons.
I keep asking myself the same initial question and when I Google, I find my own question as a top result, so here’s what resources I’ve found to help me through the whole Static vs Dynamic Canvas decisions:
A simple tutorial about correctly setting up the UI hierarchy of mixed Static and Dynamic parts of your UI:
A deeper tutorial explaining a 2-canvas setup and using the profiler to see the impact: