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 CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary 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:
The Memory Budget property determines the maximum amount of memory Unity uses for the textures in your sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary. It is set to 512MB by default. The Memory Budget has a high impact on your scene when using texture streaming. If your memory budget is too small, Unity lowers the resolution of textures in your scene. This can cause textures to pop or load slowly. However, the memory budget should be as small as possible to allow memory for other resources.
To figure out what your memory budget should be:
This makes sure there is enough texture memory available for the most resource-intensive areas of your scene and prevents textures from dropping to a lower resolution. If you have extra memory available, you can set a larger memory budget so that Unity can keep texture data that is not visible in your scene in the streaming cache.
In the Quality Settings (Edit > Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your Project behave. More info
See in Glossary > 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 GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary 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
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.
To override the mip level calculation for a specific Texture, use Texture2D.requestedMipmapLevel. This is an exact mip level ranging from 0 to the maximum mip level of the specific Texture, or the Max Level Reduction value if that is lower. 0 is the highest resolution mip.
To check if your requested mip level has loaded, use Texture2D.IsRequestedMipmapLevelLoaded.
If you no longer want to override the mip level you requested and instead want the system to continue to calculate mip map levels, use Texture2D.ClearRequestedMipmapLevel to reset the value.
To get an estimate of the UV density on a MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary, use the following:
float Mesh.GetUVDistributionMetric(int uvSetIndex)
You can use the UV distribution metric to calculate the mipmap level you need, based on the position of the Camera. See Mesh.GetUVDistributionMetric for example code.
To override the system and force all mips to load, use Texture.streamingTextureForceLoadAll.
To get and set a Texture assigned to a Material, use:
To get all Texture properties on a Material, use:
Unity has a built-in Mip Map Streaming debugging view mode. To access it, click the Scene view control drop-down and select Texture Streaming. This view mode tints GameObjects the following colours, depending on their status in the Mip Map Streaming system:
To upload Material properties for the debug modes, use Texture.SetStreamingTextureMaterialDebugProperties.
To upload Material properties for the debug modes, use the following properties:
To get information about the number of Textures or renderers the Texture Streaming system is interacting with, use the following properties:
To get information about mipmap levels for a texture, use the following properties:
You can use the Texture Streaming system to stream light maps. You can edit the Texture settings directly, but they reset to their default values when Unity regenerates the light maps. The Player SettingsSettings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary (Edit > Project Settings > Player) provide two controls to set streaming and priority for generated lightmaps: Lightmap Streaming Enabled and Streaming Priority.
Texture Streaming is enabled in Play Mode by default. However, when running in Play Mode, the Editor overheads bias the statistics. To get accurate figures, test the application on the target device.
Texture Streaming makes toggling in and out of Play Mode take slightly longer, because it needs to load extra information and more calculations. To disable Texture Streaming in Play Mode, go to the Editor Settings (Edit > Project Settings > Editor), navigate to Streaming Settings and disable Enabled Texture Streaming in Play Mode. This prevents Unity from unloading and reloading mipmap data, and should speed up the Play Mode workflow.