// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("YES"); if (!keepRunning) { keepRunning = true; Debug.Log("BEGIN"); } else { keepRunning = false; Debug.Log("END"); } } if (keepRunning) { ScreenshotHandler.TakeScreenshot_static(Screen.width, Screen.height); } }