Why is EarlyUpdate.UpdateCanvasRectTransform taking so long?

I’m profiling my game and see EarlyUpdate.UpdateCanvasRectTransform is taking over 3 seconds!
How can I make it go faster?

alt text

So I can’t really answer this as there isn’t enough information. So you have something your UI that’s changing and needing to be calculated every frame. Based on my past experiences this is meaning you have a lot of layout groups, or there’s animations inside the UI that is causing a redraw.

So check for animations in your UI. Everytime you move something it marks the entire canvas as dirty and everything needs to be recualated. You can help with this by doing a sub-canvas. When you change something, it will go up the parents until it finds a canvas/sub-canvas and then will redraw and calculate everything beneath that again the next frame.

Check out this article from Unity on optimizing your UI.

Also…LayoutGroups…Layout Groups are expensive and only use them if you have to.