Can i change Renderer.enabled from the Camera.OnPreCull?

Hello. I’d like to do some sort of custom renderer culling, and i thought disabling and enabling renderers in OnPreCull and OnPostRender is a great idea. But it turns out that it doesn’t work as expected. I wonder if enabling component in OnPreCull is too late for the engine to render it in the current frame?

PS: Disabling renderers by changing its layer works from there, but i am curious about Renderer.enable itself

I tried to enable/disable renderers in OnPreCull/OnPostRender, but it caused some issues with some type of renderers (e.g. ParticleSystem). Switching layer to ‘Invisible’ and then back to original (in OnPostRender) works fine for me.


It works fine even when doing ‘nested rendering’:

MainCamera.OnPreCull
MainCamera.WillRenderObjects
WaterReflectionCamera.OnPreCull
WaterReflectionCamera.WillRenderObjects
WaterReflectionCamera.OnPreRender
WaterReflectionCamera.OnPostRender
MainCamera.OnPreRender
MainCamera.OnPostRender