Enable a script on object in c# help

Hi there,

I’ve looked around for ways to do this, but haven’t found anything. I want to simply ‘Enable’ a script calling from a button press on another script. Once clicked, the script on the scene object is enabled. I have founds lots of .js examples. Do you have any examples of this in c#? Really stuck on this one.



YourGameObject.GetComponent(YourScript).enabled = false;

or use generics - you must add using System.Collections.Generic

YourGameObject.GetComponent<YourScript>().enabled = false;

Hey, first you should getcomponent of that script.

ScriptNameToDisable script; //creates that script data type

script = GetComponent<ScriptNameToDisable>();

script.enabled = false;