Setting up a New Data Type - Am I Doing Something Wrong?

In my current project, I’m trying to set up a new data type so I can get a script off a game object and enable/disable it on a keystroke. All of my syntax seems to be correct, except for the fact that my new data type isn’t being established as I expected it to. Currently I just have things as follows:

private ScriptToToggle script;
        public void TinSight()
        {
            script = GetComponent("ContrastEnhance");
            if (useTin == true)
            {
                Time.timeScale = 0.8f;
            }
                Time.timeScale = 1.0f;
            }
        }

I must be missing something here, because with things as they are now I get the “type or namespace name ‘ScriptToToggle’ could not be found” error. I’m sure I’m missing something obvious, but would someone mind pointing out my mistake?

Hi, here’s how you can do it if you just want a direct reference…

In this first case you will have a public ScriptToToggle variable in the Inspector and you can just drag and drop the object that contains the script to the slot and create a reference…

    public ScriptToToggle script;

    public void TinSight()
    {
        script.methodName();
        if (useTin == true)
        {
            Time.timeScale = 0.8f;
        }
        Time.timeScale = 1.0f;
    }

or alternatively you can do it like this

    public GameObject scriptToToggleObj; // same as above really, you'll need to drag and drop the object that contains the script to the inspector variable slot and create a reference
    ScriptToToggle script;
    public void Start()
    {
        script = scriptToToggleObj.GetComponent<ScriptToToggle>();
    }
    public void TinSight()
    {
        script.methodName(); // execute whatever method you want to run from the script
        if (useTin == true)
        {
            Time.timeScale = 0.8f;
        }
        Time.timeScale = 1.0f;
    }