如何在公共GameObject上显示实际的ScreenCapture纹理?
例如:
IEnumerator CaptureScreenShot()
{
yield return new WaitForEndOfFrame();
Texture2D texture = ScreenCapture.CaptureScreenshotAsTexture();
}
从这个片段中,我已经捕获了屏幕截图,现在我想在运行时将该纹理显示在公共GameObject上。
答案 0 :(得分:0)
public RawImage _rawImage;
IEnumerator CaptureScreenShot()
{
yield return new WaitForEndOfFrame();
Texture2D texture = ScreenCapture.CaptureScreenshotAsTexture();
_rawImage.texture = texture;
}
如果您需要将其作为Sprite
并将其应用于Image
或Material
,则也可以像这样使用Sprite.Create
Sprite mySprite = Sprite.Create(
texture,
new Rect(0.0f, 0.0f, texture.width, texture.height),
new Vector2(0.5f, 0.5f),
100.0f
);