I can't seem to find a way to easily change the color of the "bloom"-effect in the unity PostProcessing Stack from code. Here's what I've tried, with no effect:
var postProcessVolume = GameObject.FindObjectOfType<UnityEngine.Rendering.PostProcessing.PostProcessVolume>();
UnityEngine.Rendering.PostProcessing.Bloom bloom = postProcessVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>();
var colorParameter = new UnityEngine.Rendering.PostProcessing.ColorParameter();
colorParameter.value = mainPlayer.GenerateRandomColour();
bloom.color = colorParameter;
bloom.color.value = colorParameter.value;
bloom.enabled.value = true;
The code compiles and runs fine, but has no visual effect.
I have seen a couple of posts about this, including here and
here. I have tried all approaches I was able to find in those links, with no success.
Is there not a simple way to change the color of the "bloom"-effect from within code in Unity?
Use the Override (value) method:
Bloom bloom = postProcessVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>();
var colorParameter = new UnityEngine.Rendering.PostProcessing.ColorParameter();
colorParameter.value = Color.red;
bloom.color.Override(colorParameter);
https://docs.unity3d.com/Packages/[email protected]/manual/Manipulating-the-Stack.html