Time.timeSinceLevelLoad does not reset

Hi,

in my game I’m trying to determine how much time has passed since the start of the level. Time.timeSinceLevelLoad seemed to be the perfect built-in candidate for this. However, when tried using it, it simply did not reset at the loading of the level!

As this seems to be a pretty basic feature, I’m wondering if any of the below is causing this behaviour:

  • I’m in Editor (that is, not a build)

  • I’m reloading the same scene, not a different one

  • I’m using additive scenes and there is a secondary scene that never gets unloaded (but it’s not the active scene)

I suspect that the reason is this last one, that if not all the scenes are changed, the timer isn’t reset, but I was wondering: does someone know what exactly causes this behaviour? Is this a bug in Unity?

UPDATE: I’ve made a minimal project to test the issue, and it is certainly present (see [121801-timesincelevelstarttest.zip|121801]). Additionally, I tested that it does not happen if the scene is just normally reloaded.

BTW, I’m on Unity 2018.2.0f2.

(Note: I don’t need help in a workaround, I’ve already set up my own counter for this purpose that works perfectly. I would just like to know what is going on exactly, and possibly document an unusual/buggy behaviour of the Unity API).

Good day.

As Unity manual says “This is the time in seconds since the last level has been loaded.” I can think that you need to completly unload the levels and reload agan to reset the timer… I’m 95% sure its caused because you have opther scenes “pseudoloaded”.

Bye


Then maybe you need to cahnage the way you take the time. RUN AWAY FROM PROBLEMS! :smiley: If the timer does not reset, you need to create your own timer. store the time.time when you commence the level ina float variable called StartTime, and then everytime you need to know the time just need to

Actualtime = Time.time - StartTime

Bye again!