Give Page Feedback | API

Secondary Components - Frame Timer

This simple script measures the amount of time taken by the current frame using a Stopwatch. Each frame the stop watch is reset in the first FixedUpdate call of that frame, and then runs uninterrupted until the next frame's first FixedUpdate call. This is a very rudimentary implementation and may not work correctly if you pause your game.

You can query the frame time via the FrameTimeInMilliseconds property.

Creating A Frame Timer Component

You can add this component by selecting a game object and then selecting from the Top Menu Bar:

Component -> Deep Space Labs -> -> SAM -> Secondary Components -> Frame Timer

Adding A Frame Timer Component From The Top Menu Bar GIF

or by selecting a game object and using the Add Component menu via its inspector:

Component -> Deep Space Labs -> -> SAM -> Secondary Components -> Frame Timer

Adding A Frame Timer Component From Add Component Menu GIF

Measuring Frame Time

The Frame Timer measures frame time by starting a Stopwatch within FixedUpdate. In order for the frame time measurement to be as accurate as possible, the timer should execute before other scripts. The timer script name should automatically be added to the Script Execution Order settings (found in Project Settings), however you may want to confirm this, and if it hasn't been added, add it. Do not place other script files above this controller, unless the script file is also measuring frame time (for instance, you can and should leave the Frame Rate Dependent Execution Controller and Frame Rate Dependent Time Sliced Execution Controller above it in the Script Execution Order list, as they are more critical to the operation of Streamable Assets Manager).