您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

42 行
1.4 KiB

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
[ExecuteInEditMode]
public class RenderPipelineSwitcher : MonoBehaviour {
[Tooltip("The RenderPipelineAsset to active while behaviour is enabled. Null is a valid choice as well.")]
public RenderPipelineAsset enabledPipelineAsset;
[Tooltip("GameObjects to activate while behaviour is enabled.")]
public GameObject[] activeGameObjects;
[Tooltip("GameObjects to deactivate while behaviour is enabled.")]
public GameObject[] inactiveGameObjects;
RenderPipelineAsset m_PrevPipelineAsset;
void OnEnable() {
m_PrevPipelineAsset = GraphicsSettings.renderPipelineAsset;
GraphicsSettings.renderPipelineAsset = enabledPipelineAsset;
if(activeGameObjects != null)
foreach(var go in activeGameObjects)
go.SetActive(true);
if(inactiveGameObjects != null)
foreach(var go in inactiveGameObjects)
go.SetActive(false);
}
void OnDisable() {
GraphicsSettings.renderPipelineAsset = m_PrevPipelineAsset;
if(inactiveGameObjects != null)
foreach(var go in inactiveGameObjects)
go.SetActive(true);
if(activeGameObjects != null)
foreach(var go in activeGameObjects)
go.SetActive(false);
}
}