Texture Streaming (テクスチャストリーミング) システムは、Unity がメモリにロードするミップマップレベルを制御します。このシステムは Unity がテクスチャのために必要な合計メモリ量を削減します。なぜなら、テクスチャストリーミングシステムは、デフォルトでシーン内のすべてのミップマップをロードするのではなく、シーンの現在のカメラ位置のレンダリングに必要なミップマップのみをロードするからです。これにより、少量の CPU リソースと引き換えに、多くの GPU メモリを節約することが可能です。
テクスチャストリーミングの Memory Budget (メモリバジェット) を使用して、プロジェクトで使用するすべてのテクスチャの合計メモリ量を設定することもできます。テクスチャストリーミングシステムは自動的にミップマップレベルを下げてこの設定内に留めます。
テクスチャストリーミング API を使用して、特定のテクスチャに特定のミップマップレベルをリクエストできます。Unity は、ミップマップ選択のためのエンジンロジックを複製するサンプルの C# コードを提供しています。これを使用して、プロジェクトのためにエンジンロジックをオーバーライドできます。詳細は、テクスチャストリーミング API を参照してください。
Unity の Viking Village デモプロジェクトでは、テクスチャストリーミングはカメラの場所に応じて、テクスチャメモリの 25〜30% を節約します。
テクスチャストリーミングを有効にするには、Unity の Quality 設定 (Edit > Project Settings > Quality) に移動し、Texture Streaming チェックボックスをチェックします。これにより、テクスチャストリーミングシステム特有の設定が表示されます。各設定の詳細は、Quality 設定 を参照してください。
これを行うと、個々のテクスチャにテクスチャストリーミングを設定し、テクスチャストリーミングシステムが各テクスチャのミップマップをディスクからメモリにストリーミングできるようにします。これを行うには、テクスチャストリーミングを適用するテクスチャを選択し、インスペクターウィンドウに移動し、テクスチャインポートの設定を表示します。 Advanced 設定を開き、Streaming Mip Maps チェックボックスにチェックします。
Android 用に開発する場合は、Build Settings (ビルド設定) を開き、Compression Method を LZ4 か LZ4HC に設定する必要があります。 Unity では、テクスチャストリーミングシステムが依存する 非同期テクスチャの読み込み にそれらの圧縮方法の 1 つが必要です。
Unity loads mipmaps at the highest resolution level possible while observing the Texture Memory Budget. For more specific control, or to fine-tune the Texture Streaming system’s automatic results, use the C# API to specify mipmap levels for each Texture. For more details, see Texture Streaming API.
For Texture Streaming, you need to assign each Texture to a Unity Renderer to allow the system to calculate the required mip map level, unless a script requests manual mip levels (see documentation on Texture2D.requestedMipmapLevel). If you do not assign a Texture to a Renderer (and do not set a manually requested mip), the system cannot calculate what mip to use. This results in Unity loading the Texture with reduced mips, which look blurry when close to the Camera.
The following systems don’t use standard Renderers, so you should disable Texture Streaming on Textures associated with them:
When Unity renders a streamed Texture directly with an API (such as Graphics.DrawMeshNow) the system has no renderer bounds information to calculate the mip level, so you need to set the Texture mip level explicitly (or disable Texture streaming on this Texture). See documentation on Texture2D.requestedMipmapLevel for more details.
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.