この API を使用して、ミップマップストリーミングシステム のデフォルト設定をオーバーライドしたり、よりきめ細かい制御を行うことができます。
このページには以下の情報が含まれています。
このシステムに関する一般的な情報については、ミップマップストリーミングシステム を参照してください。
ミップマップストリーミングシステムが自動的にデフォルト設定を管理する一方で、API を使って特定の状況に応じた動作をオーバーライドすることができます。
これは、Unity が特定のテクスチャを完全にロードする必要がある場合に便利です。例えば、大きな距離をすばやく移動するゲームオブジェクトに関連する場合、または瞬間的なカメラカットを使用する場合などです。
テクスチャのミップマップストリーミングを有効にして制御するには、以下のプロパティを使用します。
Mipmap Streaming automatically reduces the mipmap 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 mipmap level that is two 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 mipmap level to fit the Memory Budget.
これらのプロパティは、実行時には読み取り専用になります。
ランタイムに発生する処理を制御するには、以下の静的プロパティを使用します。
ある場所から別の場所へ切り替えるとき、ミップマップストリーミングシステムは、必要なテクスチャを Unity にストリーミングする時間が必要とします。無効にしたターゲットカメラ位置で事前ロードを起動させるには、ターゲットカメラの Streaming Controller コンポーネントで StreamingController.SetPreloading を呼び出します。終了時間を指定して、事前ロードフェーズを終了することができます。プリロードの終了時に自動的にカメラを有効にするには、スクリプトで activateCameraOnTimeout
フラグを true に設定します。カメラから新しいカメラに切り替えた後、そのカメラを無効にするには、disableCameraCuttingFrom
パラメーターとして無効にするカメラを渡します。
void StreamingController.SetPreloading(float timeoutSeconds=0.0f, bool activateCameraOnTimeout=false, Camera disableCameraCuttingFrom=null)
プリロード状態をキャンセルまたはクエリするには、以下のメソッドを使用します。
ミップマップストリーミングシステムが依然としてテクスチャをロードしているかどうかを判断するには、以下のプロパティをクエリできます。
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 required 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 Mipmap Streaming, so you also need to set a maximum length of time before the cut.
To override the mipmap level calculation for a specific Texture, use Texture2D.requestedMipmapLevel. This is an exact mipmap level ranging from 0 to the maximum mipmap level of the specific Texture, or the Max Level Reduction value if that is lower. 0 is the highest resolution mipmap.
To check if your requested mipmap level has loaded, use Texture2D.IsRequestedMipmapLevelLoaded.
If you no longer want to override the mipmap level you requested and instead want the system to continue to calculate mipmap levels, use Texture2D.ClearRequestedMipmapLevel to reset the value.
メッシュの UV 密度の推定値を取得するには、以下を使用します。
float Mesh.GetUVDistributionMetric(int uvSetIndex)
UV 分布メトリックを使用すると、カメラの位置に基づいて、必要なミップマップレベルを計算することができます。コードサンプルは Mesh.GetUVDistributionMetric を参照してください。
To override the system and force all mipmap levels to load, use Texture.streamingTextureForceLoadAll.
デバッグ用のビジュアライゼーションを作成するために使用するマテリアルプロパティで、テクスチャごとのストリーミング情報を取得するには、Texture.SetStomengTextureMaterialDebugProperties を使用します。
Texture.SetStreamingTextureMaterialDebugProperties を使用して、各テクスチャのストリーミングステータス情報をマテリアルプロパティに割り当てます。その後、シェーダーでこれらのプロパティを使用して、デバッ グの視覚化を行うことができます。
また、これらのプロパティを使用して、プロジェクト用のミップマップストリーミングプロファイリングおよびデバッグツールを作成することも可能です。
ミップマップストリーミングシステムが相互作用するテクスチャやレンダラーの数に関する情報を取得するには、以下のプロパティを使用します。
テクスチャのミップマップレベルに関する情報を取得するには、以下のプロパティを使用します。
マテリアルに割り当てられたテクスチャを取得および設定するには、以下を使用します。
マテリアルのすべてのテクスチャプロパティを取得するには、以下を使用します。
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.