このページでは、Unity が使用しているアクティブなレンダーパイプラインの設定について説明します。このページには、ビルトインレンダーパイプライン 、ユニバーサルレンダーパイプライン (URP)、HD レンダーパイプライン (HDRP)、カスタムレンダーパイプラインに切り替える際の情報が含まれています。
別のレンダーパイプラインに切り替える場合は、プロジェクトのアセットとコードが新しいレンダーパイプラと互換性があることを確認する必要があります。そうでないと、エラーや意図しない視覚効果が発生する可能性があります。
Unity エディターでアクティブなレンダーパイプラインを設定すると、Unity はそのパイプラインでレンダリングを開始します。これには、ゲームビュー、シーンビュー、そしてプロジェクトパネルやインスペクターに表示されるマテリアルのプレビューが含まれます。
アクティブなレンダーパイプラインをビルトインレンダーパイプラインに設定するには、スクリプタブルレンダーパイプラインベースのレンダーパイプラインを使用していないことを Unity に伝える必要があります。プロジェクト設定からこれらの参照をすべて削除すると、Unity はデフォルトでビルトインレンダーパイプラインを使用するようになります。
これは以下の手順で行えます。
アクティブなレンダーパイプラインを SRP に基づいたものに設定するには、使用するレンダーパイプラインアセットを Unity に伝える必要があります。レンダーパイプラインアセットとは、どのレンダーパイプラインを使用するか、そのレンダーパイプラインをどのように設定するかについてのデータが含まれているアセットのことです。
複数のレンダーパイプラインアセットを用意し、異なる設定で同じレンダーパイプラインを使うように Unity に指示できます。例えば、ハイエンドハードウェアに適した設定を持つアセットと、ローエンドハードウェアに適した設定を持つものを用意することができます。
レンダーパイプラインアセットの概要については、スクリプトレンダーパイプライン概要 を参照してください。URP のレンダーパイプラインアセットについては、ユニバーサルレンダーパイプラインアセット を参照してください。HDRP のレンダーパイプラインアセットについては、HD レンダーパイプラインアセット を参照してください。
C# コードを使ってレンダーパイプラインアセットを設定することができます。このコードは、Unity エディターの編集モードや再生モード、またはビルドされたプレイヤーでランタイムに実行できます。
SRP は設定が非常に柔軟であるため、アクティブなレンダーパイプラインアセットの変更は非常に小さな変更になることもあれば、非常に大きな変更 (URP から HDRP への切り替えなど) になることもあります。ランタイムにレンダーパイプラインアセットを変更する場合のパフォーマンスコストは、それに応じて変化します。
新しいレンダーパイプラインアセットに切り替えると、Unity は現在のレンダーパイプラインインスタンスを破棄し、新しいレンダーパイプラインアセットの CreatePipeline()
メソッドを呼び出します。SRP のコードによっては、計算上、リソースに負担が高い操作になる場合があります。
下のサンプルコードは、GraphicsSettings.renderPipelineAsset に保存されているデフォルトの レンダーパイプラインアセットを設定する方法を示しています。
プロジェクトの Quality Settings で Quality Level (品質レベル) ごとにレンダーパイプラインアセットが割り当てられている場合は、現在の品質レベルのレンダーパイプラインアセットがデフォルトのレンダーパイプラインアセットをオーバーライドすることに注意してください。これらは、QualitySettings-renderPipeline API を使用して、以下と同じ方法で C# コードで更新できます。
using UnityEngine;
using UnityEngine.Rendering;
public class SwitchRenderPipelineAsset : MonoBehaviour
{
public RenderPipelineAsset exampleAssetA;
public RenderPipelineAsset exampleAssetB;
void Update()
{
if (Input.GetKeyDown(KeyCode.A)) {
GraphicsSettings.renderPipelineAsset = exampleAssetA;
Debug.Log("Default render pipeline asset is: " + GraphicsSettings.renderPipelineAsset.name);
}
else if (Input.GetKeyDown(KeyCode.B)) {
GraphicsSettings.renderPipelineAsset = exampleAssetB;
Debug.Log("Default render pipeline asset is: " + GraphicsSettings.renderPipelineAsset.name);
}
}
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.