Version: 2023.2
public static Rendering.AsyncGPUReadbackRequest Request (ComputeBuffer src, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (GraphicsBuffer src, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (ComputeBuffer src, int size, int offset, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (GraphicsBuffer src, int size, int offset, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (Texture src, int mipIndex, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (Texture src, int mipIndex, TextureFormat dstFormat, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (Texture src, int mipIndex, Experimental.Rendering.GraphicsFormat dstFormat, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, TextureFormat dstFormat, Action<AsyncGPUReadbackRequest> callback);
public static Rendering.AsyncGPUReadbackRequest Request (Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, Experimental.Rendering.GraphicsFormat dstFormat, Action<AsyncGPUReadbackRequest> callback);

参数

src 要从中读取数据的资源。
size Size in bytes of the data to be retrieved from the ComputeBuffer or GraphicsBuffer.
offset Offset in bytes in the ComputeBuffer or GraphicsBuffer.
mipIndex 要获取的 Mipmap 的索引。
dstFormat 数据的目标 TextureFormat。如果目标格式与 GPU 中存储的格式不同,则转换是自动进行的。
x 要获取的纹理数据的起始 X 坐标(以像素为单位)。
width 要获取的纹理数据的宽度(以像素为单位)。
y 要获取的纹理数据的起始 Y 坐标(以像素为单位)。
height 要获取的纹理数据的高度(以像素为单位)。
z 正在获取的 Texture3D 的起始 Z 坐标(以像素为单位)。正在获取的 TextureCube、Texture2DArray 和 TextureCubeArray 的起始层索引。
depth 正在获取的 Texture3D 的深度(以像素为单位)。TextureCube、TextureArray 和 TextureCubeArray 的层数。
callback 完成请求后调用的可选委托 System.Action。完成的请求作为参数传递给 System.Action。

返回

AsyncGPUReadbackRequest 返回 AsyncGPUReadbackRequest,可用于确定数据何时可用。否则,返回带有错误的请求。

描述

从 GPU 资源中异步获取数据。

如果返回了带有错误的请求,则调用 AsyncGPUReadbackRequest.hasError 将返回 true。

For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.

For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.

If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961