private static IEnumerator CaptureScreenRectShot(Canvas cans, RectTransform rect, bool bTimeLine) { Rect targetRect = GameFunction.GetSpaceRect(cans, rect, cans.worldCamera); Int32 timestamp = (Int32)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string screenshotname = GameDefine.ScreenshotSavePath + timestamp.ToString() + ".png"; yield return(new WaitForEndOfFrame()); Texture2D tex = new Texture2D((int)targetRect.width, (int)targetRect.height, TextureFormat.RGBA32, false); tex.ReadPixels(targetRect, 0, 0); tex.Apply(); File.WriteAllBytes(screenshotname, tex.EncodeToPNG()); while (!File.Exists(screenshotname)) { yield return(new WaitForSeconds(0.05f)); } WeChat_ShareImageByPath(screenshotname, bTimeLine); }