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

时间:2016-02-07 06:48:09

标签: user-interface unity3d screenshot

如何截取特定的UI元素?

在我的情况下,我需要屏幕捕获UI面板,其中包含UI文本,UI输入等子对象。

请看一下图片。提前致谢

enter image description here

1 个答案:

答案 0 :(得分:2)

您需要知道要复制的框的尺寸。然后将值传递给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

相关问题