- Home /
Time.unscaledDeltaTime problem on android when app minimized and maximized?
I wrote this simple script:
 private int counter = 0;
 void Update()
 {
     print( (counter++) + " | Time.unscaledDeltaTime: " +Time.unscaledDeltaTime);
 }
When I now start this app in android I get something like this:
 35 | Time.unscaledDeltaTime: 0.02269688
When I minimize the app now and wait e.g. like 3 seconds and maximize the app again I get this:
 36 | Time.unscaledDeltaTime: 3.097296
 37 | Time.unscaledDeltaTime: 0.004942969
 38 | Time.unscaledDeltaTime: 0.01963734
Why I get this big impact with unscaledDeltaTime? I use unscaledDeltaTime, because in the game I use
 Time.timescale = 0.0F;
Any ideas how can I solve this? Maybe a coroutine?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Bongmo · Mar 03, 2019 at 01:00 PM
I kind of solved this. This is the idea.
 private int counter = 0;
 private bool active = true;
 void Update()
 {
     if (active)
         print( (counter++) + " | Time.unscaledDeltaTime: " +Time.unscaledDeltaTime);
 }
 void OnApplicationPause(bool pauseStatus)
 {
     bool isPaused = pauseStatus;
     
     if (isPaused) {
         active = false;
     }
     else
     {
         StartCoroutine( SetActiveToTrue() );
     }    
 }
 private IEnumerator SetActiveToTrue()
 {
     yield return new WaitForEndOfFrame();
     
     active = true;
     
     yield return null;
 }
Your answer
 
 
             Follow this Question
Related Questions
Time.deltaTime not returning time since last frame? 1 Answer
TimeScale = 0 crashes Unity 1 Answer
Setting fixeddeltatime depending on TimeScale makes physics behave weirdly 1 Answer
Math.Abs slows down on time.timescale 0 Answers
2nd independent deltaTime and timeScale variables, or a way to mimic this? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                