IEnumerator CaptureScreen(Connect conn, MessageModel request) { var rect = new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 1f, Screen.height * 1f); Texture2D screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false); yield return(new WaitForEndOfFrame()); screenShot.ReadPixels(rect, 0, 0); screenShot.Apply(); string dir = UtilsHelper.GetDataPath() + "temp/"; if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } var fn = dir + "shapshot.jpg"; var data = screenShot.EncodeToJPG(); System.IO.File.WriteAllBytes(fn, data); var url = WWWCache.Instance.AddCustomData("temp/shapshot.jpg", fn); conn.SendImage(request, url + "?gid=" + Time.realtimeSinceStartup); }