src | 有关源纹理或标识符,请参阅 RenderTargetIdentifier。 |
dst | 有关目标纹理或标识符,请参阅 RenderTargetIdentifier。 |
srcElement | 源纹理元素(立方体贴图面、纹理数组层或 3D 纹理深度切片)。 |
srcMip | 源纹理的 Mipmap 级别。 |
dstElement | 目标纹理元素(立方体贴图面、纹理阵列层或 3D 纹理深度切片)。 |
dstMip | 目标纹理的 Mipmap 级别。 |
srcX | 要复制的源纹理区域(左侧为零)的 X 坐标。 |
srcY | 要复制的源纹理区域(底部为零)的 Y 坐标。 |
srcWidth | 要复制的源纹理区域的宽度。 |
srcHeight | 要复制的源纹理区域的高度。 |
dstX | 目标纹理中的复制目标区域(左侧为零)的 X 坐标。 |
dstY | 目标纹理中的复制目标区域(底部为零)的 Y 坐标。 |
添加用于将纹理复制到其他纹理中的命令。
此函数可在纹理之间高效复制像素数据。
源和目标元素可以为纹理、立方体贴图、纹理阵列层或 3D 纹理深度切片。可以指定 Mipmap 级别以及源和目标子区域。
因为复制不执行任何缩放操作,所以源和目标像素尺寸必须相同。
纹理格式应该兼容(例如,TextureFormat.ARGB32 和 RenderTextureFormat.ARGB32 兼容)。
有关格式兼容的确切规则因图形 API 而异。始终可以复制完全相同的格式。
在一些平台(例如,D3D11)上,还可以在位宽度相同的格式之间进行复制。
压缩纹理格式通过区域变体对 CopyTexture 添加了一些限制。例如,不支持 PVRTC 格式,
因为该格式不基于方块(对于这些格式,您只能复制整个纹理或整个 Mipmap 级别)。
对于基于方块的格式(例如,DXT、ETC),区域大小和坐标必须是压缩方块大小的倍数(对于 DXT 为 4 倍像素)。
如果源和目标纹理都标记为“可读”(即系统内存中存在
用于 CPU 读取/写入的数据副本),则会同时在系统内存和 GPU 中复制数据。
有些平台可能没有进行各种纹理复制的功能(例如,从渲染纹理
复制到常规纹理中)。请参阅 CopyTextureSupport 并使用 SystemInfo.copyTextureSupport 进行检查。
另请参阅:Graphics.CopyTexture、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.