1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Unity] Built-inとURP(SRP)を切り替える

Posted at

プロジェクトを新規作成するとき、URPにするか、Built-inにするか、悩んでいませんか?

Built-in URP(SRP)

実はBuilt-inとURP(SRP)、スクリプトから結構簡単に切り替えられるんです。

Built-inのシーン上に、URPのオブジェクト(左) と、Built-inのオブジェクト(右) を置きます

image.png

下記スクリプトを空のオブジェクトにアタッチし、

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

[HelpURL("https://docs.unity3d.com/ja/2021.2/Manual/srp-setting-render-pipeline-asset.html")]
public class CoreUrpChange : 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);
        }
    }
}

Aは空に、BにURPのRenderPipelineAssetをセットします。
image.png

実行し、A、Bのキーを押すとBuilt-in,URPが切り替わります。

A B
image.png image.png
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?