版本: Unity 6 (6000.0)
语言英语
  • C#

QualitySettings.renderPipeline

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。尽管我们无法接受所有提交,但我们确实会阅读用户提出的每个建议更改,并在适用时进行更新。

关闭

提交失败

由于某些原因,您的建议更改无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

切换到手册
public static Rendering.RenderPipelineAsset renderPipeline;

描述

定义当前质量等级覆盖渲染管线的RenderPipelineAsset

这是当前质量等级的覆盖渲染管线。如果此值为 null,则当前质量等级不存在覆盖值。

Unity 使用此值和 GraphicsSettings.renderPipeline 中定义的默认渲染管线来确定当前质量等级的活动渲染管线。有关更多信息,请参阅 GraphicsSettings.currentRenderPipeline

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"); } } }