I am using an advanced color correction image effect with curves set to particular settings.
I'd like to either be able to attach multiple instances of the image effect to the camera and enable and disable them with a script, or save and reload the curves to and from a variable set.
I haven't seen any obvious ways to reference multiple effects on the same camera. Can I define image effects on different game objects/prefabs and then point the camera to them at runtime? Or copy their contents?
For separate effects you could call `GetComponent(WhateverImageEffect)` on the camera, then use the `enabled` property of the component to activate and deactive it.
For instances of the same effect, you could add all the components in your own array, and then use the objects in the array:
WhateverImageEffect[] effects;
WhateverImageEffect currentEffect;
public void Start()
{
effects = GetComponents<WhateverImageEffect>();
currentEffect = effects[0];
currentEffect.enabled = true; //assumes all effects are deactivated on startup.
}
public void SetEffect(int effectIndex)
{
currentEffect.enabled = false;
currentEffect = effects[effectIndex];
}
If you need the order to be the same between runs guaranteed, you could implement your own image effect class, extended from the original, with an extra ID field included. You can then use this to map the effects: