---@param rectTransform UnityEngine.RectTransform function this.CaptureScreenshot(rectTransform) local rect=rectTransform.rect local screenPos=this.GetUICamera():WorldToScreenPoint(rectTransform.position) local newRect=UnityEngine.Rect(screenPos.x-math.abs(rect.x),screenPos.y-math.abs(rect.y),rect.width,rect.height) coroutine.yield(UnityEngine.WaitForEndOfFrame()) local texture=UnityEngine.Texture2D(newRect.width, newRect.height, UnityEngine.TextureFormat.RGB24, false) texture:ReadPixels(newRect, 0, 0) texture:Apply()
texture:EncodeToPNG()
return texture end