I'm trying to imitate a lightning effect in Unity using its post-processing stack's bloom effect via script (to modify the intensity), but somehow I'm unable to actually set anything via script.
PostProcessingProfile postProcProf;
postProcProf.bloom.settings.bloom.intensity =
Mathf.Lerp(data[i].Strength, data[i + 1].Strength, data[i].TimeToReachNext);
This is my code, but it says
Cannot modify the return value of BloomModel.Settings, because it is not a variable.
I have found no guide on how to script post-processing stack, only on how to use it from the editor.
As per Unity's guide on modifying post-processing at runtime, you should be modifying a copy of the settings
value, then overwriting the original with your copy (don't try to change members of BloomModel.Settings
directly):
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;