src | The source texture or RenderTargetIdentifier. |
dst | The destination texture or RenderTargetIdentifier. |
srcElement | The element in the source texture to copy from. For example, the CubemapFace in a Cubemap or the slice in a texture array. Set the value to 0 if src is a 2D texture. |
srcMip | The mipmap level to copy from. The range is 0 through the texture's Texture.mipmapCount. The default value is 0 . |
dstElement | The element in the source texture to copy to. For example, the CubemapFace in a Cubemap or the slice in a texture array. Set the value to 0 if `dst` is a 2D texture. |
dstMip | The mipmap level to write to. The range is 0 through the texture's Texture.mipmapCount. The default value is 0 . |
srcX | The starting x coordinate of src to copy from. 0 is the left of the texture. |
srcY | The starting y coordinate of src to copy from. 0 is the bottom of the texture. |
srcWidth | The width of src to copy. |
srcHeight | The height of src to copy. |
dstX | The x coordinate of dst to copy to. |
dstY | The y coordinate to dst to copy to. |
Adds a command to copy pixel data from one texture to another.
This method adds a command to copy pixel data from one texture to another on the GPU. If you set Texture.isReadable to true
for both src
and dst
textures, the method also copies pixel data on the CPU.
If you set Texture.isReadable to false
, CopyTexture
is one of the fastest ways to copy a texture. But to use CopyTexture
, the following must be the same in both the source and destination texture areas:
Format. You can also use two compatible formats - for example, TextureFormat.ARGB32 and RenderTextureFormat.ARGB32.
Size.
RenderTexture.antiAliasing values, if the textures are render textures.
You might be able to copy between incompatible formats depending on your graphics API. For example, on some APIs you can copy between formats with the same bit width.
Depending on your graphics API, you might not be able to copy between different types of textures. For more information on compatibility, see SystemInfo.copyTextureSupport and CopyTextureSupport.
If src
is a depth-only render texture, you must copy the whole texture, not part of it. A depth-only render texture has its color buffer set to a color format of None
and its depth buffer set to a valid RenderTexture.depthStencilFormat.
Compressed texture formats add some restrictions to the CopyTexture with a region variant. For example, PVRTC formats are not supported since they are not block-based (for these formats you can only copy whole texture or whole mipmap level). For block-based formats (for instance, DXT, ETC), the region size and coordinates must be a multiple of compression block size (4 pixels for DXT).
Even if you set Texture.isReadable
to true, this method doesn't copy pixel data on the CPU if you copy only a region of a compressed texture.
See Also: 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.