We have a large group of self-laid-out UGUI objects (~200), mostly ones with Image components. In other words, there is no grid or H/V layout groups as parents. With or without a parent ScrollRect (also a layout group, apparently), and being inside a RectMask2D, I’m seeing 150+ms hit for activating and also deactivating the parent of these objects in the Unity 2020.3.18f1 Editor (release scripts). Both times it’s due to marking the layout for rebuild, which calls GetComponents on every object (see table below). The layout doesn’t need to be rebuilt because these aren’t positioned by anything. Again, removing the parent ScrollRect doesn’t seem to avoid this, so how the heck can I stop this from happening? Thank you!!
BUMP
After trying different things and profiling, we we able to remove the unnecessary “mark layout rebuild” by replacing UGUI Image with Sprite Renderer but this still left a ton of these weird RectTransform.SendReapplyDrivenProperties calls, which also mark the layout for rebuild. This seems odd to me because we don’t have any layout groups or content size fitters that might “drive” the RectTransform properties.
Finally we decided to completely ditch RectTransform and go with 100% sprites and write our own pointer event system to handle clicks and enter/exit events. Regardless, we’d still like to understand the purpose of these calls, so if a Unity engineer could weight-in, I’d appreciate it.
BUMP - can anyone from Unity comment on this?
Obviously I’m no Unity Engineer and I highly doubt that they will drop by here.
But if you’re interested, they just released a blog post and a fairly short webinar about the nitty-gritty of UGUI recently.
Plus it still worth checking out the famous Unite presentation of Ian Dundore.
This issue seems to be the same as the following issue.
The page above says this issue has been fixed in 2020.3.19f1, but unfortunately I think this still remains even in the latest LTS 2020.3.21f1.
(Actually, this seems to be “fixed” in the latest 2021.1 and 2021.2…)
I submitted a bug report to Unity yesterday.