c# - 编写 Unity 后处理堆栈脚本

标签 c# unity-game-engine post-processing

我试图通过脚本使用其后处理堆栈的绽放效果来模仿Unity中的闪电效果(以修改强度),但不知何故我无法实际设置 通过脚本执行任何操作。

PostProcessingProfile postProcProf;
postProcProf.bloom.settings.bloom.intensity = 
Mathf.Lerp(data[i].Strength, data[i + 1].Strength, data[i].TimeToReachNext);

这是我的代码,但它说

Cannot modify the return value of BloomModel.Settings, because it is not a variable.

我没有找到有关如何编写脚本后处理堆栈的指南,仅介绍了如何从编辑器中使用它。

最佳答案

根据 Unity's guide on modifying post-processing at runtime ,您应该修改 settings 值的副本,然后用您的副本覆盖原始值(不要尝试直接更改 BloomModel.Settings 的成员):

PostProcessingProfile postProcProf;
var bloom = postProcProf.bloom.settings;
bloom.bloom.intensity = Mathf.Lerp(data[i].Strength, data[i + 1].Strength, data[i].TimeToReachNext);
postProcProf.bloom.settings = bloom;

关于c# - 编写 Unity 后处理堆栈脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45200829/

相关文章:

javascript - 使用JS自动从文本底部显示引用书目

C# 包装器和回调

Android View 未接收到触摸

unity-game-engine - 沿其旋转方向移动子弹

android - Unity3DGenerateManifest.cs

ios - 在后处理中启用 Unity3D xCode 项目的功能

c# - 使用 int 作为符号有什么意义?

c# - 由于 DontDestroyOnLoad() 导致重复

c# - 使用 async/await 和 TaskCompletionSource 的奇怪堆栈跟踪增长

html - 如何对 HTML 进行后处理以将 "target blank"添加到 Ruby 中的所有链接?