このページには、Unity が現在使用しているレンダーパイプラインの取得と設定の方法についての情報を掲載しています。Unity が現在使用しているレンダーパイプラインは、アクティブレンダーパイプラインと呼ばれます。
Unity は、コンテンツのレンダリングにビルトインレンダーパイプライン、または、ユニバーサルレンダーパイプライン (URP) や HD レンダーパイプライン (HDRP) など スクリプタブルレンダーパイプライン (SRP) に基づくレンダーパイプラインのいずれかを使用することができます。
Unity が使用するスクリプタブルレンダーパイプラインは、レンダーパイプラインアセットを使用して指定します。レンダーパイプラインアセットは、どの SRP を使用するか、またそれをどのように設定するかを Unity に伝えます。レンダーパイプラインアセットを指定しない場合、Unity はビルトインレンダーパイプラインを使用します。
同じレンダーパイプラインを使用する複数のレンダーパイプラインアセットを作成し、異なる設定にすることが可能です。例えば、ハードウェアのレベルによって異なるレンダーパイプラインアセットを使用することができます。レンダーパイプラインアセットに関する一般的な情報は、スクリプタブルレンダーパイプラインの概要 を参照してください。URP のレンダーパイプラインアセットについては ユニバーサルレンダーパイプラインアセット、HDRP のレンダーパイプラインアセットについては HD レンダーパイプラインアセット を参照してください。
Unity エディターやランタイムでアクティブなレンダーパイプラインを変更すると、すぐに Unity が新しいアクティブなレンダーパイプラインを使用してコンテンツをレンダリングします。Unity エディター 内では、ゲームビュー、シーンビュー、そして Project パネルと Inspector のマテリアルのプレビューがこれに含まれます。
アクティブなレンダーパイプラインを変更する場合は、プロジェクト内のアセットとコードが新しいレンダーパイプラインと互換性があることを確認する必要があります。そうでない場合、エラーや、意図しないビジュアル効果が発生する可能性があります
アクティブなレンダーパイプラインは、Graphics 設定 (グラフィックス設定) と Quality 設定 (品質設定) の両方を使用して決定されます。Graphics 設定では、Unity がデフォルトで使用するレンダーパイプラインを設定できます。Quality 設定では、デフォルトのレンダーパイプラインを品質レベルごとにオーバーライドできます。
デフォルトのレンダーパイプラインを取得または設定するには、Graphics 設定 > Scriptable Render Pipeline Setting (またはこれに相当する API: GraphicsSettings.defaultRenderPipeline) を使用します。特定の品質レベルのデフォルトをオーバーライドするレンダーパイプラインを取得または設定するには、Quality 設定 > Render Pipeline (またはこれに相当する API: QualitySettings.renderPipeline) を使用します。
Unity は、アクティブなレンダーパイプラインを以下のように決定します。
エディター UI でアクティブなレンダーパイプラインを取得するには、Graphics 設定と Quality 設定の両方のウィンドウを確認する必要があります。これらの値を使用してアクティブなレンダーパイプラインを決定する方法については、アクティブなレンダーパイプラインの決定 を参照してください。
ビルトインレンダーパイプラインをアクティブなレンダーパイプラインとして設定するには、Graphics 設定と Quality 設定からレンダーパイプラインアセットを削除してください。
これは以下の手順で行えます。
SRP ベースのレンダーパイプラインをアクティブなレンダーパイプラインとして設定するには、デフォルトのアクティブなレンダーパイプラインとして使用するレンダーパイプラインアセットと、(任意で) 各品質レベルで使用するレンダーパイプラインアセットを指定します。
これは以下の手順で行えます。
C# スクリプトで、アクティブなレンダーパイプラインを取得および設定し、アクティブなレンダーパイプラインが変更された時にコールバックを受け取ることができます。これは、Unity エディターの編集モードまたは再生モード、あるいはアプリケーションのランタイムで行うことができます。
これを行うには、以下の API を使用してください。
以下のコードサンプルは、これらの API の使用方法を示したものです。
using UnityEngine;
using UnityEngine.Rendering;
public class ActiveRenderPipelineExample : MonoBehaviour
{
// In the Inspector, assign a Render Pipeline Asset to each of these fields
public RenderPipelineAsset defaultRenderPipelineAsset;
public RenderPipelineAsset overrideRenderPipelineAsset;
void Start()
{
GraphicsSettings.defaultRenderPipeline = defaultRenderPipelineAsset;
QualitySettings.renderPipeline = overrideRenderPipelineAsset;
DisplayCurrentRenderPipeline();
}
void Update()
{
// When the user presses the left shift key, switch the default render pipeline
if (Input.GetKeyDown(KeyCode.LeftShift)) {
SwitchDefaultRenderPipeline();
DisplayCurrentRenderPipeline();
}
// When the user presses the right shift key, switch the override render pipeline
else if (Input.GetKeyDown(KeyCode.RightShift)) {
SwitchOverrideRenderPipeline();
DisplayCurrentRenderPipeline();
}
}
// Switch the default render pipeline between null,
// and the render pipeline defined in defaultRenderPipelineAsset
void SwitchDefaultRenderPipeline()
{
if (GraphicsSettings.defaultRenderPipeline == defaultRenderPipelineAsset)
{
GraphicsSettings.defaultRenderPipeline = null;
}
else
{
GraphicsSettings.defaultRenderPipeline = defaultRenderPipelineAsset;
}
}
// Switch the override render pipeline between null,
// and the render pipeline defined in overrideRenderPipelineAsset
void SwitchOverrideRenderPipeline()
{
if (QualitySettings.renderPipeline == overrideRenderPipelineAsset)
{
QualitySettings.renderPipeline = null;
}
else
{
QualitySettings.renderPipeline = overrideRenderPipelineAsset;
}
}
// Print the current render pipeline information to the console
void DisplayCurrentRenderPipeline()
{
// GraphicsSettings.defaultRenderPipeline determines the default render pipeline
// If it is null, the default is the Built-in Render Pipeline
if (GraphicsSettings.defaultRenderPipeline != null)
{
Debug.Log("The default render pipeline is defined by " + GraphicsSettings.defaultRenderPipeline.name);
}
else
{
Debug.Log("The default render pipeline is the Built-in Render Pipeline");
}
// QualitySettings.renderPipeline determines the override render pipeline for the current quality level
// If it is null, no override exists for the current quality level
if (QualitySettings.renderPipeline != null)
{
Debug.Log("The override render pipeline for the current quality level is defined by " + QualitySettings.renderPipeline.name);
}
else
{
Debug.Log("No override render pipeline exists for the current quality level");
}
// If an override render pipeline is defined, Unity uses that
// Otherwise, it falls back to the default value
if (QualitySettings.renderPipeline != null)
{
Debug.Log("The active render pipeline is the override render pipeline");
}
else
{
Debug.Log("The active render pipeline is the default render pipeline");
}
// To get a reference to the Render Pipeline Asset that defines the active render pipeline,
// without knowing if it is the default or an override, use GraphicsSettings.currentRenderPipeline
if (GraphicsSettings.currentRenderPipeline != null)
{
Debug.Log("The active render pipeline is defined by " +GraphicsSettings.currentRenderPipeline.name);
}
else
{
Debug.Log("The active render pipeline is the Built-in Render Pipeline");
}
}
}
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.