Version: 2021.3
public void ConvertTexture (Rendering.RenderTargetIdentifier src, int srcElement, Rendering.RenderTargetIdentifier dst, int dstElement);

参数

src 源纹理。
dst 目标纹理。
srcElement 源元素(例如,立方体贴图面)。对于 2D 源纹理,请将此值设置为 0。
dstElement 目标元素(例如,立方体贴图面或纹理数组元素)。

描述

转换源纹理并将其复制到具有不同格式或尺寸的目标纹理。

This function provides an efficient way to convert between textures of different formats and dimensions. The destination texture format must be uncompressed and correspond to a RenderTextureFormat supported on the current device. You can use 2D and cubemap textures as the source and 2D, cubemap, 2D array and cubemap array textures as the destination. This function does not support conversion from cubemap to Texture2D. It also does not support RenderTexures. Instead, use Graphics.Blit.

This function operates only on GPU-side data. Use Texture2D.ReadPixels to get the pixels from GPU to CPU.

Due to API limitations, this function is not supported on DX9 or Mac+OpenGL. Some platforms don't support every type of texture conversion. This is because this function internally depends on functionality from Graphics.CopyTexture. To check if your target platform supports the type of texture conversion you are using, use SystemInfo.copyTextureSupport. For more information on compatibility, see Graphics.CopyTexture and CopyTextureSupport.

另请参阅:CopyTextureSupport