.enabled in c#?

im trying to enable a component in c# but i dont know what the correct code is to enable a component. im using this:

if(GUI.Button(new Rect(50, 100, 183, 25), "Restart Level")){
            
			Application.LoadLevel("Training Layout");
			Time.timeScale = 1.0f;
			player.GetComponent<MouseLook>.enabled = true;
                        cam.GetComponent<MouseLook>.enabled = true;
                        cam.GetComponent<ShowSkin>.enabled = false;
            }

but it says that enabled is an unknown command. what is the correct syntax to enable or disable a component in c#?

try:

cam.GetComponent<ShowSkin>().enabled = false;

The syntax for generics is (), not .

–Eric

As for why you need to use those weird <> in addition to (), it’s because you’re using the generics version of GetComponent. It’s the more convenient of the two options,

player.GetComponent().enabled = true;

vs

((MouseLook)player.GetComponent(typeof(MouseLook))).enabled = true

Generics are just
The () there, ie () comes from the fact that this is calling a function and functions just need (), it has nothing to do with generics.

thanks all i got it figured out (: