Delta time/per-tick operations in Immediate Mode

Avatar
  • updated

Using Immediate Mode, I observed that DrawShapes(Camera cam) will be called multiple times each render in-editor, once for each Game and Scene window. This can result in any per-frame/time operations having different results in editor versus builds.

A simple fix for this can include modifying your logic if the camera is not the primary camera. For example:

public override void DrawShapes(Camera camera)
{ float delta = Time.deltaTime;

#if UNITY_EDITOR
if (camera != Camera.main)
{
delta = 0f;
}
#endif ...
Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline