This page contains the following sections:
Use the API to apply more control over how Unity streams Textures. You can override which mipmap level to load for specific Textures, while the Texture Streaming system automatically manages all other Textures. You might have specific gameplay scenarios where you know that Unity needs to fully load certain Textures. For example, moving large distances quickly, or using instantaneous Camera cuts, can cause noticeable Texture quality changes while the Texture Streaming system streams the mipmaps from the disk into memory. To reduce this problem, you can use the API to preload mipmaps at a new Camera location .
To enable and control Texture Streaming on a Texture, use the following properties:
Texture Streaming automatically reduces the size of Textures until they fit into the Texture 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 Texture Streaming system tries to use a mipmap 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.
These are read-only at run time:
To control what happens at run time, use the following static properties:
QualitySettings.streamingMipmapsMemoryBudget (defaults to 512 MB)
QualitySettings.streamingMipmapsRenderersPerFrame (defaults to 512)
QualitySettings.streamingMipmapsMaxLevelReduction (defaults to 2)
QualitySettings.streamingMipmapsMaxFileIORequests (defaults to 1024)
To control the way Unity caches unused mip levels via script, use Texture2D.streamingTextureDiscardUnusedMips. It’s useful to set this to false for initial testing to check metrics, and to set a Memory Budget (set in Quality Settings when Texture Streaming is enabled, or via QualitySettings.streamingMipmapsMemoryBudget), otherwise Unity doesn’t drop any mips. The Memory Budget is set to 512MB by default.
In the Quality Settings (Edit > Project Settings > Quality), use Add All Cameras to specify whether Unity should calculate Texture Streaming for all Cameras in the Project. This is enabled by default.
For fine-grain control over which Cameras are active, use the Streaming Controller component on the same GameObject as the Camera component. This takes the location and Camera settings (such as Field of View) directly from the Camera component.
If the Camera is disabled, Unity does not calculate Texture Streaming for it, unless the Streaming Controller is enabled and in the preloading state. When the Streaming Controller and associated Camera are enabled, or if the Streaming Controller is in a preloading state, then Unity calculates Texture Streaming for this Camera. If the Streaming Controller is disabled, then Unity does not calculate Texture Streaming for this Camera.
The Streaming Controller component contains the Mip Map Bias setting. To control this via API, use StreamingController.streamingMipmapBias.
Use this setting to force Unity to load smaller or larger mipmap levels than the Texture Streaming system has chosen for those Textures. Use the numerical field to set the offset that Unity applies to the mipmap level. Unity adds this offset to all Textures visible from this Camera.
When cutting from one location to another, the Texture 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 cancel or query the preloading state, use the following methods:
To determine whether the Texture 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 Texture Streaming system calculates the mipmaps 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 Texture Streaming, so you also need to set a maximum length of time before the cut.