how to turn components on and off in unity through code code example
Example: how to turn components on and off in unity through code
//enable
GetComponent<Collider>().enabled = true;
//disabled
GetComponent<Collider>().disabled = false;
//enable
GetComponent<Collider>().enabled = true;
//disabled
GetComponent<Collider>().disabled = false;