Version: 2023.2
public void GetData (Array data);
public void GetData (Array data, int managedBufferStartIndex, int computeBufferStartIndex, int count);

参数

data 用于接收这些数据的数组。
managedBufferStartIndex 数据中的第一个元素索引,从该位置起复制已获取元素。
computeBufferStartIndex The first element index of the buffer from which elements are read.
count 要获取的元素数量。

描述

将该缓冲区中的数据值读取到数组中。该数组只能使用 blittable 类型。

获取的数据将遵循正在使用的图形 API 的数据布局规则。请参阅计算着色器以了解跨平台兼容性信息。

Note that this function reads the data back from the GPU, which can be slow. If any GPU work has been submitted that writes to this buffer, Unity waits for the tasks to complete before it retrieves the requested data, guaranteeing this function returns the most up to date results. For this reason, you should use AsyncGPUReadback instead because it performs the request in the background, and allows you to check when the result is available, without blocking the main thread.

注意:只有 blittable 数据类型可以从缓冲区复制到数组,数组的类型必须是 blittable 类型。如果您尝试使用非 blittable 类型,则会引发异常。

另请参阅:SetDatacountstride