by everything i mean the components. For instance, when i use gameObject.SetActive(false)–>the game object is deactivated but every component is on. The object still moves(if a move script is attach). If it has a mesh collider it is still on, and the player can still get hit by it. (It is not like the gameobject.active that applies that basicly shuts it down untill is reactivated.)
_ I don’t know if this is a bug
Using Unity 4.0.0b11
You can use gameObject.SetActiveRecursively(onOff: boolean): this disables everything (children included), making the object disappear completely:
gameObject.SetActiveRecursively(false); // disable object and children
If you just want to disable all the scripts, however, you should get all MonoBehaviour components and disable them:
var scripts: Component[] = GetComponentsInChildren(MonoBehaviour);
for (var script: MonoBehaviour in scripts){
script.enabled = false;
}
But notice that this only disables the periodic functions - Update, FixedUpdate, LateUpdate, OnGUI etc. Events like OnTriggerEnter still may occur, and it’s also possible to call any function via SendMessage - this may be useful to reactivate the script, like below:
function EnableMe(){ // call this function via SendMessage("EnableMe")
enabled = true; // re-enable the script
}