De-activate script that deactives all the members of an array ?

Essentially what im trying to build is a utillity script that i can use to optomise my level. Essentially i already have a number triggers that turn un-necessary objects off when a player passes through certain triggers. This time around i want to do the same thing but on a larger scale.

var Targets : GameObject[];
function OnTriggerEnter (other : Collider) {
    Targets.SetActiveRecursively(false);
}

Obviously this doesn't work. So how do i make it work ?

You need a foreach loop:

C#

foreach (GameObject go in Targets) {
    go.SetActiveRecursively(false);
}

UnityScript hm ... does UnityScript have foreach?

EDIT: Yes, it does, well ... it's just not called foreach ;-)

for (var target in Targets) {
    target.SetActiveRecursively(false); 
}

So ... you don't really need:

for (var i = 0; i < Targets.Length; i++) {
    Targets*.SetActiveRecursively(false);*
*}*
*```*
*<p>;-)</p>*
*<p>Btw: In general, I'd recommend having member variables in camel-case, so instead of</p>*
*```*
*var Targets: GameObject[];*
*```*
*<p>You may consider writing</p>*
*```*
*var targets : GameObject[];*
*```*
*<p>EDIT2: So this is what this would look like (based on your original code):</p>*
*```*
*var targets : GameObject[];*
*function OnTriggerEnter (other : Collider) {*
 *for (var target in targets) {*
 *target.SetActiveRecursively(false);* 
 *}*
*}*
*```*