width | 宽度(以像素为单位)。 |
height | 高度(以像素为单位)。 |
depthBuffer | 深度缓冲区位(0、16 或 24)。注意,仅 24 位深度具有模板缓冲区。 |
format | 渲染纹理格式。 |
readWrite | 颜色空间转换模式。 |
antiAliasing | 要存储在纹理中的抗锯齿样本数。有效值为 1、2、4 和 8。如果传递任何其他值,则抛出异常。 |
memorylessMode | 渲染纹理无内存模式。 |
vrUsage | How Unity uses the RenderTexture as a VR eye texture. The default is VRTextureUsage.None. |
useDynamicScale | Determines whether Unity scales the render texture using dynamic resolution. The default is false . |
desc | 创建临时 RenderTexture 时,可将此 RenderTextureDesc 用于设置。 |
分配临时渲染纹理。
有时,您可能需要快速创建一个 RenderTexture 来进行一些临时的计算,该函数已针对这种情况做了优化。
使用完 RenderTexture 后,请立即使用 ReleaseTemporary 释放它,
以便下次需要时可以再次调用来重用它。
在内部,Unity 保留一个临时渲染纹理池,
因此调用 GetTemporary 通常只是直接返回一个已创建的渲染纹理(如果大小和格式匹配)。
如果若干帧都不使用这些临时渲染纹理,才将它们实际销毁。
如果您需要进行一系列后期处理“blit”,
则对于每个 blit,获取和释放一个临时渲染纹理要比
事先获取一到两个渲染纹理并进行重用的性能更好。
这对于移动(基于区块的)和多 GPU 系统来说最为有益:GetTemporary 将在内部执行 DiscardContents 调用,
有助于避免对先前的渲染纹理内容进行代价高昂的恢复操作。
您不能依赖从 GetTemporary 函数获得的 RenderTexture 的任何特定内容。
这些可能是垃圾内容,也可能被清除为某种颜色,具体视平台而定。
另请参阅:ReleaseTemporary。
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.