How to switch between filters by scripts
-
One of the best way is to simple link the effects directly with the inspector
In this example, we will add 2 effect, Broken screen, and Fx 8bits
Add the effect to the Camera
Then, create a new script SwitchCameraFilterPack
public class SwitchCameraFilterPack : MonoBehaviour { public CameraFilterPack_Broken_Screen Fx1; // Add here the right filter component public CameraFilterPack_FX_8bits Fx2; // Add here the right filter component // Use this for initialization void Start () { // desactive both effect on start Fx1.enabled = false; Fx2.enabled = false; } // Update is called once per frame void Update () { if (Input.GetKeyDown(KeyCode.LeftArrow)) { Fx1.enabled = true; Fx2.enabled = false; } if (Input.GetKeyDown(KeyCode.RightArrow)) { Fx1.enabled = false; Fx2.enabled = true; } } }
Now drag and drop the camera gameobject on FX 1 and FX 2, the right component will be automaticly detected
After that, press play and switch from Left or Right to change the effects ! :)