如何在脚本中控制Unity post-processing V2属性?

How to control Unity post-processing V2 attributes in script?

我正在尝试调整我已应用的 post 处理配置文件的晕影属性,但不知道如何通过脚本执行此操作。在旧版本中,您必须声明一个新的 post-processing 配置文件,设置值并将新配置文件分配回现有配置文件。但是,我似乎无法在新版本中执行此操作,并且通过查看 Unity 手册提到了 Manipulating the Stack 和 Writing Custom Effects,其中 AddSettings() 方法似乎是最有前途的。但是,当我在 Start 方法中尝试 blurProfile.AddSettings<Vignette>().intensity = new FloatParameter { value = 0 }; 时,检查器中的值保持不变。

我将如何在脚本中更改这些属性?

由于您正在使用新的 Post-Processing Stack,您可以使用指令

访问其组件
using UnityEngine.Rendering.PostProcessing;

因此对于小插图,您将使用:

Vignette vignetteLayer = null;
vignetteLayer.intensity = new FloatParameter { value = 0 };

从 unity 论坛查看 official documentation for more information and also this question,了解有关新 Post-Processing Stack

的更多信息