您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
44 行
1.3 KiB
44 行
1.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Experimental.Rendering;
|
|
using UnityEngine.Rendering.HighDefinition;
|
|
|
|
namespace UnityEngine.Experimental.Rendering.HDPipelineTest
|
|
{
|
|
[ExecuteInEditMode]
|
|
public class RenderPipelineSwitcher : MonoBehaviour
|
|
{
|
|
HDRenderPipelineAsset previousPipeline = null;
|
|
public HDRenderPipelineAsset targetPipeline = null;
|
|
|
|
void OnEnable ()
|
|
{
|
|
if(previousPipeline == null)
|
|
{
|
|
previousPipeline = (GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset);
|
|
}
|
|
if (targetPipeline != null && GraphicsSettings.renderPipelineAsset != targetPipeline)
|
|
{
|
|
GraphicsSettings.renderPipelineAsset = targetPipeline;
|
|
}
|
|
}
|
|
void Update()
|
|
{
|
|
if (previousPipeline == null)
|
|
{
|
|
previousPipeline = (GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset);
|
|
}
|
|
if(targetPipeline != null && GraphicsSettings.renderPipelineAsset != targetPipeline)
|
|
{
|
|
GraphicsSettings.renderPipelineAsset = targetPipeline;
|
|
}
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
GraphicsSettings.renderPipelineAsset = previousPipeline;
|
|
}
|
|
}
|
|
}
|