Version: 2021.2
언어: 한국어

ScreenCapture.CaptureScreenshotIntoRenderTexture

매뉴얼로 전환
public static void CaptureScreenshotIntoRenderTexture (RenderTexture renderTexture);

파라미터

renderTexture RenderTexture that will get filled with the screen content.

설명

Captures a screenshot of the game view into a RenderTexture object.

This variant of screen capture makes it possible to read pixels asynchronously using AsyncGPUReadback, making the process consume less time on the main thread.

For information on when to invoke this method, see the note in ScreenCapture.CaptureScreenshotAsTexture.

using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;

public class ScreenCaptureIntoRenderTexture : MonoBehaviour { private RenderTexture renderTexture;

IEnumerator Start() { yield return new WaitForEndOfFrame();

renderTexture = new RenderTexture(Screen.width, Screen.height, 0); ScreenCapture.CaptureScreenshotIntoRenderTexture(renderTexture); AsyncGPUReadback.Request(renderTexture, 0, TextureFormat.RGBA32, ReadbackCompleted); }

void ReadbackCompleted(AsyncGPUReadbackRequest request) { // Render texture no longer needed, it has been read back. DestroyImmediate(renderTexture);

using (var imageBytes = request.GetData<byte>()) { // do something with the pixel data. } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961