0
我是Unity新手。我正在嘗試製作一個代碼,它將在scrollview中獲取對象的屏幕截圖。我的問題是,scrollView內的整個對象/圖像在設備中不可見。您必須平移scrollView才能看到隱藏的部分。我想要做的是在scrollview中截取整個對象/圖像的屏幕截圖。請幫助統一:在scrollView內容拍屏幕時遇到問題
我下面的代碼是
private IEnumerator TakeScreenshot()
{
yield return new WaitForEndOfFrame();
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] screenshot = tex.EncodeToPNG();
}
以上代碼只需要截圖是在設備屏幕上。我想截取整個對象/圖像的截圖。請幫助