src | 源纹理。 |
dst | 目标纹理。 |
srcElement | 源纹理元素(立方体贴图面、纹理数组层或 3D 纹理深度切片)。 |
srcMip | 源纹理的 Mipmap 级别。 |
dstElement | 目标纹理元素(立方体贴图面、纹理阵列层或 3D 纹理深度切片)。 |
dstMip | 目标纹理的 Mipmap 级别。 |
srcX | 要复制的源纹理区域(左侧为零)的 X 坐标。 |
srcY | 要复制的源纹理区域(底部为零)的 Y 坐标。 |
srcWidth | 要复制的源纹理区域的宽度。 |
srcHeight | 要复制的源纹理区域的高度。 |
dstX | 目标纹理中的复制目标区域(左侧为零)的 X 坐标。 |
dstY | 目标纹理中的复制目标区域(底部为零)的 Y 坐标。 |
复制纹理内容。
该函数可在纹理之间高效复制像素数据。
此外,它还可以从元素(例如立方体贴图面)或特定的 Mip 级别以及纹理的子区域进行复制。
复制不进行任何缩放,也就是说,源和目标的大小必须相同。纹理格式应该兼容
(例如,TextureFormat.ARGB32 和 RenderTextureFormat.ARGB32 兼容)。有关格式兼容的确切规则因图形 API 而异;
一般说来,始终可以在完全相同的格式之间进行复制。
在某些平台(例如,D3D11)上,还可以在位宽度相同的格式之间进行复制。
压缩纹理格式通过区域变体对 CopyTexture 添加了一些限制。例如,不支持 PVRTC 格式,
因为该格式不基于方块(对于这些格式,您只能复制整个纹理或整个 Mip 级别)。
对于基于方块的格式(例如,DXT、ETC),区域大小和坐标必须是压缩方块大小的倍数
(对于 DXT 为 4 倍像素)。
如果源和目标纹理都标记为“可读”(即系统内存中存在
用于 CPU 读取/写入的数据副本),这些函数也将复制它。
有些平台可能没有全部纹理复制的功能(例如,从渲染纹理
复制到常规纹理中)。请参阅 CopyTextureSupport 并使用
SystemInfo.copyTextureSupport 进行检查。
在 CopyTexture
之后调用 Texture2D.Apply、Texture2DArray.Apply 或 Texture3D.Apply 会产生未定义的结果,因为 CopyTexture
以独占方式对 GPU 端数据进行操作,而 Apply
会将数据从 CPU 端传输到 GPU 端。
另请参阅:CopyTextureSupport。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.