The Unity docs clearly explain that game objects marked static should not be moved for performance reasons but I can't find any info regarding enabling / disabling.

Almost everything in my games levels is destructible so I only use real-time GI. When the player damages a game object enough it's either removed or replaced with a damaged version of the model, usually via an object pool.

What effect does enabling or disabling a static game object have on performance?

When you set a GameObject as static, Unity starts optimising behind the scenes and assuming stuff about your objects. If for example you mark multiple objects as "batching static" you are basically telling Unity that these objects will never move. This means there is a chance on your final game all these objects will be "merged together" as one mesh, and be rendered like that, to make performance faster.

This is just one example, as far as I know the optimisation behaviour in Unity is not defined, and can be different from platform to platform as different things can be faster or slower on specific devices.

Although I can't know in detail, I image that when you are disabling/enabling static objects in a scene, you interfere with these optimisations, as it's not possible to disable part of a mesh.

A simple rule is, if your GameObject is not really static and needs to be moved or be altered in any other way, do not mark it as static. Make sure you are not trying to prematurely optimise your project, make something that works, and when that's done, only then start optimising on the most performance-intensive parts.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.