Unity3D - 特定 UI 元素的屏幕截图

Unity3D - Screen Capture of particular UI elements

如何截取特定 UI 个元素?

在我的例子中,我需要屏幕截图 UI 带有子对象的面板,例如 UI 文本、UI 输入等

请看图片。提前致谢

您需要知道要复制的盒子的尺寸。然后将值传递给 ReadPixels 方法

float width = boxWidth;
float height = boxHeight;
float x = boxXPosition;
float y = boxYPosition;    
var tex = new Texture2D( 1, 1, TextureFormat.RGB24, false );
tex.ReadPixels( new Rect(x,y,width,height), 0, 0 );
tex.Apply();

http://docs.unity3d.com/ScriptReference/Texture2D.ReadPixels.html