Reputation: 307
I have an update function that will check if something is equal to true and if it is equal to true it will run some code but then I want the whole script to be disabled. Please help, thanks!
Upvotes: 7
Views: 47202
Reputation: 1
You can disable script component by using the following syntax,
GameObject.Find("Cube").GetComponent<MoveObject>().enabled = false;
Here I disable the MoveObject script from the object named Cube.
Upvotes: 0
Reputation: 11
This will work:
public GameObject otherobj;//your other object
public string scr;// your secound script name
void Start () {
(otherobj. GetComponent(scr) as MonoBehaviour).enabled = false;
}
Upvotes: 0