I’m trying to add a new ColorGrading PP effect in code, when the user clicks a button, and I’ve read multiple questions and Unity’s docs, and it just isn’t working for me.
My code uses Unity’s “QuickVolume” call and while there’s no error, nothing happens (and clicking my “PostFx” object in the hierarchy, while in game, shows no effect added).
GameObject postFx = GameObject.Find("PostFx");
PostProcessVolume volume = postFx.GetComponent<PostProcessVolume>();
ColorGrading colorGradingSettings = ScriptableObject.CreateInstance<ColorGrading>();
var colorGradingModeParameter = new GradingModeParameter
{
value = GradingMode.LowDefinitionRange
};
BoolParameter boolParam = new BoolParameter();
boolParam.value = true;
FloatParameter floatParam = new FloatParameter();
floatParam.value = -100f;
colorGradingSettings.enabled = boolParam;
colorGradingSettings.gradingMode = colorGradingModeParameter;
colorGradingSettings.saturation = floatParam;
PostProcessManager.instance.QuickVolume(postFx.layer, 100f, colorGradingSettings);
(I think I could skip the *Parameter() instantiations and just assign the *.value property of each directly but I’m not concerned with that right now)
Instead of the “QuickVolume” call, I’ve also tried instead using the “volume.profile.AddSettings(colorGradingSettings)” call instead but that produces a bunch of errors, including “array index out of bounds” or similar, and some other one.
Anyone know what’s wrong with this? I wish the docs were more clear; this should be super easy to do and the docs should explicitly state how to do it. Ugh.