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
    0_1523002345132_0e833d85-793c-4393-a692-4c92d2f6670c-image.png

    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

    0_1523002382271_c3e4cf49-b3da-4c45-9f43-8cbf262224ac-image.png

    After that, press play and switch from Left or Right to change the effects ! :)


 

Looks like your connection to Vetasoft Assets was lost, please wait while we try to reconnect.