UnityEngine.Rendering 中的类
/
继承自:ScriptableObject
/
实现接口:ISerializationCallbackReceiver
一个 ScriptableObject,用于与 RenderPipeline 关联,并为该 Pipeline 存储项目范围的设置。
可以通过 GraphicsSettings.RegisterRenderPipelineSettings 将单个 RenderPipelineGlobalSettings 实例注册到 GraphicsSettings。我们建议使用此 ScriptableObject 来保存您在 GraphicsSettings 中找到的 RenderPipeline 设置。
using System; using System.Collections.Generic;
using UnityEngine; using UnityEngine.Rendering;
#if UNITY_EDITOR using UnityEditor.Rendering; #endif
public class ExampleRenderPipelineAsset : RenderPipelineAsset { protected override RenderPipeline CreatePipeline() { return new ExampleRenderPipeline(); } }
public class ExampleRenderPipeline : RenderPipeline { public virtual RenderPipelineGlobalSettings globalSettings => ExampleRPGlobalSettings.instance;
protected override void Render(ScriptableRenderContext renderContext, Camera[] cameras) { #if UNITY_EDITOR // On Editor we must make sure the Global Settings Asset is registered into the GraphicsSettings // Graphics Settings will make sure the asset is available on player builds if (globalSettings == null) { var mySettings = ExampleRPGlobalSettings.Create(); ExampleRPGlobalSettings.RegisterToGraphicsSettings(mySettings); } #endif
// Do something } }
[SupportedOnRenderPipeline(typeof(ExampleRenderPipelineAsset))] public class ExampleRPGlobalSettings : RenderPipelineGlobalSettings { private static ExampleRPGlobalSettings cachedInstance = null; public static ExampleRPGlobalSettings instance { get { if (cachedInstance == null) cachedInstance = GraphicsSettings.GetSettingsForRenderPipeline<ExampleRenderPipeline>() as ExampleRPGlobalSettings; return cachedInstance; } }
/* Use this pattern if you want to enable your global settings to use IRenderPipelineGraphicsSettings
[SerializeReference] private List<IRenderPipelineGraphicsSettings> m_SettingsList = new(); protected override List<IRenderPipelineGraphicsSettings> settingsList => m_Settings;
*/
#if UNITY_EDITOR public static void RegisterToGraphicsSettings(ExampleRPGlobalSettings newSettings) { EditorGraphicsSettings.SetRenderPipelineGlobalSettingsAsset<ExampleRenderPipeline>(newSettings as RenderPipelineGlobalSettings); cachedInstance = null; }
public static void UnregisterToGraphicsSettings() { EditorGraphicsSettings.SetRenderPipelineGlobalSettingsAsset<ExampleRenderPipeline>(null); cachedInstance = null; }
static public ExampleRPGlobalSettings Create() { ExampleRPGlobalSettings assetCreated = ScriptableObject.CreateInstance<ExampleRPGlobalSettings>(); return assetCreated; } #endif }
settingsList | 公开一个 List<IRenderPipelineGraphicsSettings>,此 RenderPipelineGlobalSettings 实例正在管理该列表。 |
Initialize | 初始化 RenderPipelineGlobalSettings 的仅编辑器功能。 |
Add | 将 IRenderPipelineGraphicsSettings 接口添加到此 RenderPipelineGlobalSettings 资产实例中。 |
Contains | 如果给定的 ISRPGraphicsSetting 类型存在于此 RenderPipelineGlobalSettings 实例中。 |
GetSettingsImplementingInterface | 获取当前活动管道中实现 TSettingsInterfaceType 的所有设置。 |
Remove | 从此 RenderPipelineGlobalSettings 资产实例中删除 IRenderPipelineGraphicsSettings 接口。 |
TryGet | 在此 RenderPipelineGlobalSettings 资产实例中查找 IRenderPipelineGraphicsSettings 接口,如果找到则返回 true。 |
TryGetFirstSettingsImplementingInterface | 尝试获取第一个实现 TSettingsInterfaceType 的设置。 |
GetInstanceID | 获取对象的实例 ID。 |
ToString | 返回对象的名称。 |
Destroy | 删除 GameObject、组件或资产。 |
DestroyImmediate | 立即销毁对象 obj。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 加载新场景时不要销毁目标对象。 |
FindAnyObjectByType | 检索类型为 type 的任何活动加载对象。 |
FindFirstObjectByType | 检索类型为 type 的第一个活动加载对象。 |
FindObjectsByType | 检索类型为 type 的所有加载对象的列表。 |
Instantiate | 克隆对象 original 并返回克隆。 |
InstantiateAsync | 捕获原始对象(必须与某个 GameObject 相关)的快照,并返回 AsyncInstantiateOperation。 |
CreateInstance | 创建可脚本化对象的实例。 |
bool | 对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用是否引用同一个对象。 |