I have a couple of GameObjects in Designer that serve purely as configuration so I can change it from designer itself without going through the code. I’ve noticed that I can remove an update() method on those GameObjects and Unity doesn’t complain. The question is - does something still gets executed every frame on these objects costing me performance (even with update() removed)?
Yes, an empty Update function is still called; it just returns immediately without doing anything. Always remove unused functions.
–Eric
… you can just disable the monobehaviour script though with .enabled = false; if you want it to avoid doing that and keep Update for whatever reason (ie lots of ai objects that begin to update as you get closer).
I understand the solution with enabling/disabling monobehaviours - will use it. Thanks. The answer from Eric5h5 is still not clear though. I’m not leaving update() method empty. I’m removing it all together. So unless Unity simply calls something on a base monobehaviour every frame or generates empty update() for me - there is nothing for it to call.
In that case you should remove it. The same applies to any other empty (built-in) function which might be called from Unity directly, like Start(), Awake(), OnCollisionEnter() and so on. If they don’t do anything, make sure to remove them, otherwise they will still be called as Eric5h5 mentioned.
If they are not present Unity will not call them.
Thank you, Glockenbeat! That answers my question fully and means that I can continue using my GameObjects for scene configuration without performance loss since I would remove update() calls. Awesome!