Deactivate a edge detection effect on camera with a key

i’m quite confuse on this, i’m trying to acces a script on my camera wich is part of the unity effect, the edge detection script.
trying to enable it and disable it with a key

my code is

```csharp
*using UnityEngine;
using System.Collections;

public class test_scriptenabler : MonoBehaviour
{

void Update()
{
    ed = Camera.main.EdgeDetection;

    if (Input.GetKey(KeyCode.Space))
    {
        ed.enabled = !ed.enabled;
    }
}

}
_```*_

well i’m getting an error " Assets/Script/test_scriptenabler.cs(13,27): error CS0103: The name `ed’ does not exist in the current context "

i dont understand why ?

Two issues going on.

Your compiler error is because you need to declare “ed” before you use it. e.g. “EdgeDetection ed = …”

The Camera class also doesn’t have a member variable named “EdgeDetection”. I’m guessing you meant .GetComponent()

Also, GetKey will be true for every frame you’re holding spacebar, so the effect will flicker on and off while you hold it. Use .GetKeyDown or .GetKeyUp instead.

yeah well thx for the answer but i dont understand where the hell and most of all wich kind of declaration form i need to use, before void start or in update, i’m kinda new to code and it’s not very simple for me

hence i understand the GetComponent use

thx for trying