// [RMS] disabling main camera allows Update loop to continue, but // it doesn't come back cleanly... //Camera mainCamera; public void Update() { if (initialized == false) { if (DisableVSync) { QualitySettings.vSyncCount = 0; } Application.targetFrameRate = ActiveFramerate; start_framerate = Application.targetFrameRate; start_vsync = QualitySettings.vSyncCount; initialized = true; } Vector3 new_mouse_pos = Input.mousePosition; // cancel idle if mouse moved if (Application.isFocused && ((new_mouse_pos - last_mouse_pos).magnitude > 0.0001 || Input.anyKeyDown)) { last_mouse_pos = new_mouse_pos; last_move_time = Time.realtimeSinceStartup; if (IdleStage != IdleStages.NoIdle) { to_active_framerate(); IdleStage = IdleStages.NoIdle; } return; } double time_delta = Time.realtimeSinceStartup - last_move_time; // fall into successively deeper idle states if (time_delta > InitialIdleDelay && IdleStage == IdleStages.NoIdle) { //DebugUtil.Log("Starting idle! {0}", FPlatform.RealTime()); Application.targetFrameRate = 15; if (DisableVSync == false) { QualitySettings.vSyncCount = 0; } //mainCamera = Camera.main; //mainCamera.enabled = false; IdleStage = IdleStages.InitialIdle; } if (time_delta > DeepIdleDelay && IdleStage == IdleStages.InitialIdle) { //DebugUtil.Log("Starting deep idle! {0}", FPlatform.RealTime()); Application.targetFrameRate = 5; if (DisableVSync == false) { QualitySettings.vSyncCount = 0; } //mainCamera = Camera.main; //mainCamera.enabled = false; IdleStage = IdleStages.DeepIdle; } }
public void OnApplicationFocus(bool focus) { if (IdleStage != IdleStages.NoIdle) { to_active_framerate(); IdleStage = IdleStages.NoIdle; last_move_time = Time.realtimeSinceStartup; } }