Version: 2019.3
Creating a Render Pipeline Asset and Render Pipeline Instance
Scheduling and executing rendering commands in the Scriptable Render Pipeline

Setting the active Render Pipeline Asset

In the Scriptable Render Pipeline (SRP), your Project must have an active Render Pipeline Asset. This page contains information on setting the Render Pipeline Asset for your Project, in the Unity Editor and at runtime.

Compatibility and performance

Because SRP is highly configurable, changing the active Render Pipeline Asset can result in a very minor change, such using the same Render Pipeline Instance with a different quality tier, or a very large change, such as switching from the Universal Render Pipeline (URP) to the High Definition Render Pipeline (HDRP).

If you change the active Render Pipeline Asset to one that uses a different Render Pipeline Instance, you must ensure that the assets and code in your Project are compatible with the new Render Pipeline Instance. Otherwise, you might experience errors or unintended visual effects.

Also note that swapping to a new Render Pipeline Asset causes Unity to destroy the current Render Pipeline Instance, and call the new Render Pipeline Asset’s CreatePipeline() method. Depending on the code in your SRP, this might be a computationally resource-intensive operation.

Setting a Render Pipeline Asset in the Unity Editor

You need to set a Render Pipeline Asset in the Unity Editor so that you can work with SRP while you edit your Project. The Render Pipeline Asset that you set in the Editor is the one that Unity uses by default in the built player.

Set the Render Pipeline Asset for your Project in the Graphics Settings window.

  1. Open the Graphics Settings window by navigating to Edit > Project Settings > Graphics.
  2. In your Project folder, locate the Render Pipeline Asset that you want to use.
  3. Drag the Render Pipeline Asset onto the Scriptable Render Pipeline Setting field. Unity immediately begins renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
    See in Glossary
    with SRP using the configuration you defined in the Render Pipeline Asset. This includes the Game view, the Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
    See in Glossary
    , and previews for Materials that are displayed in the Project panel and the InspectorA Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. More info
    See in Glossary
    .

Setting a Render Pipeline Asset at runtime

You can set the Render Pipeline Asset at runtime if you want to switch between Render Pipeline Assets. You can do this in the built player, or in Play Mode in the Editor.

At runtime, set the Render Pipeline Asset using the GraphicsSettings.renderPipelineAsset API.

The following example code shows how to switch between two Render Pipeline Assets.

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("Active render pipeline asset is: " + GraphicsSettings.renderPipelineAsset.name);
        }
        else if (Input.GetKeyDown(KeyCode.B)) {
            GraphicsSettings.renderPipelineAsset = exampleAssetB;
            Debug.Log("Active render pipeline asset is: " + GraphicsSettings.renderPipelineAsset.name);
        }
    }
Creating a Render Pipeline Asset and Render Pipeline Instance
Scheduling and executing rendering commands in the Scriptable Render Pipeline
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961