I haven’t visited this in awhile, but I do have some more, mostly useless information that probably doesn’t help.
I believe I was wrong when I thought Collider2D/Rigidbody2D played a role in the lag. They do contribute but they’re not the actual problem.
I have two versions of my main project that branched from each other at around 2019.1.
They’re roughly 90% identical except one is the ‘main’ one and one I just made for testing random things and packages and assets I didn’t want to muddy the main project.
My main project is the one with the issue that I brought up with this post after updating to 2019.3. I only just now realized my test project which is what I first updated to 2020.1 a few days ago has the same ‘issue’ but to a much lesser extent despite being roughly the same. To test, I updated my main project to 2020.1 and it still has this issue.
I believe now that the issue is likely due to something I must have done on my end somehow.
Here is the profiler of my main project again of the significant lag when drawing the inspector with a problem object selected.
In my test project, to clarify, the same problem is actually still there in the profiler, but to a less extent so I didn’t notice it because it never brought me to a noticeably low framerate.
Here’s profiler of test project with same exact object selected in a different but similar scene (which shouldn’t matter because all the lag is coming from editor drawing the inspector).
Important to note that these spikes only occur when one of the objects I’m selecting is changing in some way in the scene, such as transform being updated (in play mode, which happens every frame). I understand that it must be the inspector needing to update values of the monobehaviors and transforms which requires some amount of garbage creation, but what I don’t understand is why it’s so different between my two projects, and why updating to 2019.3 originally caused such a significant drop in performance that 2020.1 didn’t fix for me. And again the backup versions of the project (that are 99.9% identical) that open with 2019.1 and 2018.3 and below don’t have the issue at all.
The reason it’s a problem is that when in play mode, this large inspector drawing time of the selected objects is added to the regular playerloop time, which drops fps well below 60. So it makes testing script changes of those objects’ impossible since I have to have them selected to see inspector values, but the fps is dragged to a slow from all the inspector garbage creation which makes it so I can’t reliably playtest anything.
It has to be a mixture of something I’m doing on my end that 2019.3+ handles differently and doesn’t like, but I can’t imagine what. I’m not using any custom inspector script on the problem objects. Not sure what else to do to figure out why.
Minimizing all components including the transform component on the object has some beneficial effect but doesn’t fix the problem.