IEnumerator StartVideo() { UnityWebRequest www = UnityWebRequest.Get(Consts.playStopURL); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); flowormotor = 0; System.Threading.Thread.Sleep(2000); StartCoroutine(StartVideo()); } else { Debug.Log(www.downloadHandler.text); if (www.downloadHandler.text.Contains("1")) { sphereRenderer.material.shader = flippedsphereshader; transformScript.Recenter(); //videos[vid].playbackSpeed = 10;//debug purposes videos[vid].Play(); //File.AppendAllText(filePath, System.Environment.NewLine + "init," + System.DateTime.Now.ToString() + "," + "video" + vid); Debug.Log("Play Video"); if (vid == 3)//when started with 0 : if (vid == 0) { StartCoroutine(VerifyServo()); StartCoroutine(VerifySceneRestart()); } } else { flowormotor = 0; System.Threading.Thread.Sleep(2000); StartCoroutine(StartVideo()); //SceneManager.LoadScene(SceneManager.GetActiveScene().name); } } }