Use this API to override the default settings in the Mipmap Streaming system, or get more fine-grained control.
本页包含以下信息:
For general information about this system, see Mipmap Streaming system.
You can use the API to override behavior for specific situations, while the Mipmap Streaming system automatically manages the default settings.
This is useful if you know that Unity needs to fully load certain textures; for example, if they relate to GameObjects that move large distances quickly, or if you use instantaneous camera cuts.
To enable and control Mipmap Streaming on a texture, use the following properties:
Mipmap Streaming automatically reduces the mip level of textures until they fit into the Mipmap Streaming Memory Budget. The Texture’s Mip Map Priority number is roughly a mipmap offset for the Memory Budget. For example, with a priority of 2, the Mipmap Streaming system tries to use a mip that is two mip levels higher than other textures with a priority of 0. Negative values are also valid. If it can’t do this, it uses a lower mip level to fit the Memory Budget.
以下属性在运行时为只读:
要控制运行时的行为,请使用以下静态属性:
When cutting from one location to another, the Mipmap Streaming system needs time to stream the required Textures into Unity. To trigger preloading at a disabled target Camera location, call StreamingController.SetPreloading on the target Camera’s Streaming Controller component. You can specify a time-out to end the preloading phase. To automatically enable the Camera at the end of the preloading phase, set the activateCameraOnTimeout
flag to true in script. To disable a Camera after you cut from it to the new one, pass that Camera as the disableCameraCuttingFrom
parameter.
void StreamingController.SetPreloading(float timeoutSeconds=0.0f, bool activateCameraOnTimeout=false, Camera disableCameraCuttingFrom=null)
要取消或查询预加载状态,请使用下列方法:
To determine whether the Mipmap Streaming system is still loading Textures, you can query the following properties:
Note that there is delay between when you enable a Camera and when these properties become a value other than zero. This delay is because the Mipmap Streaming system calculates the mip maps using time-sliced processing. For this reason, during a Camera cut you should wait a minimum length of time before the cut. Texture budget and Scene movement can cause continuous Mipmap Streaming, so you also need to set a maximum length of time before the cut.
要覆盖特定纹理的 Mip 级别计算,请使用 Texture2D.requestedMipmapLevel。这是一个精确的 Mip 级别,范围从 0 到特定纹理的最高 Mip 级别或者是 Max Level Reduction 值(如果该值更大)。0 表示最高分辨率的 Mip。
要检查您请求的 Mip 级别是否已加载,请使用 Texture2D.IsRequestedMipmapLevelLoaded。
If you no longer want to override the mip level you requested and instead want the system to continue to calculate mip levels, use Texture2D.ClearRequestedMipmapLevel to reset the value.
要估算网格上的 UV 密度,请使用以下代码行:
float Mesh.GetUVDistributionMetric(int uvSetIndex)
可以使用 UV 分布指标根据摄像机的位置来计算所需的 Mipmap 级别。请参阅 Mesh.GetUVDistributionMetric 以查看代码示例。
要覆盖系统并强制加载所有 Mip,请使用 Texture.streamingTextureForceLoadAll。
要获取可用于创建调试可视化的材质属性中每个纹理串流信息,请使用 Texture.SetStreamingTextureMaterialDebugProperties。
You can use Texture.SetStreamingTextureMaterialDebugProperties to assign streaming status information for each texture to material properties. You can then use these properties in the shader to create debug visualizations.
You can also use these properties to create Mipmap Streaming profiling and debugging tools for your project.
To get information about the number of Textures or renderers the Mipmap Streaming system is interacting with, use the following properties:
要获取有关纹理的 Mipmap 级别的信息,请使用以下属性:
要获取和设置分配给某一材质的纹理,请使用:
要获取某一材质中的所有纹理属性,请使用:
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.