- Home /
Should non-rendered (code only) GameObjects be marked as static
Does anyone know if it's beneficial to mark non-rendered GameObjects as static?
For instance if I have a GameObject that only contains code - nothing that actually needs moving, lighting etc - does Unity still do some processing that'd be reduced by marking it as Static?
Interesting question... I suspect it makes no difference if the object has no renderer/collider component attached, but I'd be interested to hear that confirmed.
Aside from renderers, colliders, draw call batching, lightmap builds, occlusion culling, and navmesh generation, I'm not aware of anything in Unity that takes the static flag(s) into account. In those circumstances, static/non-static matters a lot; outside of them, I'm pretty sure it matters none at all, or as near as makes no practical difference.
I just ran some tests myself to make sure and posted an answer. I can confirm that setting static for non-rendered objects has no effect.
Answer by Nition · Nov 05, 2013 at 01:48 AM
Answering my own question because I ran some tests on it.
I set VSync off and TargetFrameRate to unlimited, then spawned 100,000 GameObjects with a simple script on each that did nothing graphical. The scene also contained a camera and the original spawner object.
In a build, I could see no difference in framerate between having them static or not. In the editor, there might be a very slight difference, or I could just be imagining things. Either way it doesn't matter.
In short, setting static or not seems to have no effect on non-rendered GameObjects.
Answer by Josh707 · Nov 05, 2013 at 01:57 AM
It will have no effect if an object does not have a mesh renderer or particle system.
From the documentation: Unity can combine a number of objects at runtime and draws them together with a single draw call. This operation is called "batching". The more objects Unity can batch together, the better rendering performance (on the CPU side) you can get. Static batching allows the engine to reduce draw calls for geometry of any size (provided it does not move and shares the same material). If several objects shared the same geometry before static batching, then a copy of geometry will be created for each object, either in the Editor or at runtime. Currently, only Mesh Renderers and Particle Systems are batched.
I assumed so but even with the documentation, I thought it possible that Unity could be doing some $$anonymous$$or internal stuff to all GameObjects since they all still have transforms etc. Checking the position of non-static objects each frame or something like that. Anyway, I've now tested and confirmed that yeah, setting Static or not has no effect on performance for non-rendered objects.
Yeah it's always worth just trying stuff out to see what happens anyways!
Your answer
![](https://koobas.hobune.stream/wayback/20220613121241im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Static List< GameObject> in Singleton 1 Answer
Why is text ui cant be static ? 0 Answers
GameObject Static & Active Flags 1 Answer
static weapons? 1 Answer
GetInstanceID ?????? 2 Answers