BCE0019: 'enabled' is not a member of 'UnityEngine.Component' when using List

Hi,

I get this error when trying to enable/disable a script: BCE0019: ‘enabled’ is not a member of ‘UnityEngine.Component’. The script I am trying to target is chosen from a List array.

I have learned that ‘Component’ does not have the function ‘enabled’ and I would normally use the name of the script itself to correct the problem as I am using #pragma strict. However I am having problems working out how to declare the script name when using a list array.

Here is some example code that works without pragma strict, but fails with it.

#pragma strict
import System.Collections.Generic;

var addComponentsHere = new List.<Component>();

function Start () {
	addComponentsHere[0].enabled = true;
	addComponentsHere[1].enabled = false;
	addComponentsHere[2].enabled = true;
}

Thanks!

Paul

‘enabled’ comes from Monobehaviour, so how about a list of Monobehavours.