Hello
I need to subscribe a function to BindToRenderStep, but only for part of the playtime.
The condition for this may change each 20-30 sec, although sometimes it may not change for few minutes.
From performance point of view is it better to subscribe/unsubscribe to to BindToRenderStep, each time when the condition changes
or it is better to subscribe once and only verify the condition inside the function?
If your function requires a lot of resources, it is better to unsubscribe it from BindToRenderStep. However, if your function and the condition are simple, the overhead on the processor will be insignificant.
The verification whether the function will continue is fast - checking several attributes of object.
But still it is something which will be executed on each frame, so 60 times per second.
So I wonder how heavy is subscribing/unsubscribing to the Render step, compared to this.
If the “verification” is checking several attributes per frame, then it will technically be slower than calling BindToRenderStep every 30 seconds.
Of course, all of this is negligible. This isn’t the difference between 2 FPS and 200, it’s probably only going to save a few hundred microseconds, if you’re lucky, either way.