toggling components in c#

im trying to make components on another object toggle by a button, i click once they change but when i click again they stay the same and don’t change back.

public GameObject DragCamera; 


	void Start () {

		DragCamera.GetComponent<MinimalSensorCamera>().enabled = false;
		DragCamera.GetComponent<Mouselook2>().enabled = true;

	}

	void OnClick () {

		DragCamera.GetComponent<MinimalSensorCamera>().enabled = true;
		DragCamera.GetComponent<Mouselook2>().enabled = false;


	}

thanks in advance

Of course, because you are setting fixed values in OnClick, you should have:

public GameObject DragCamera; 
MinimalSensorCamera sensorCam;
Mouselook2 mouseLook;

void Start () {
	// Cache this for better performance, since you're using them more times in OnClick
	sensorCam = DragCamera.GetComponent<MinimalSensorCamera>();
	mouseLook = DragCamera.GetComponent<Mouselook2>();
	sensorCam.enabled = false;
	mouseLook.enabled = true;
	
}

void OnClick () {
	// Invert enabled/disabled state
	sensorCam.enabled = !sensorCam.enabled;
	mouseLook.enabled = !mouseLook.enabled;
}