disabling scripts doesn't work in 2.6 and my views reset

Are these common Unity 2.6 bugs or is my install somehow corrupted?

When I disable a script component, some script still run when I play my game. (enable/disable checkbox for the components)
Weird thing is that this doesn’t happen with all scripts.

Another problem is with the 4 split layout,
if I remember correct, in 2.5 had default top and side views, now they all have the same perspective view. And to make it worse they also reset to perspective views after I played the game from the editor.

Depending on what you mean by “run”, that’s always happened and is by design. Disabling a script disables Update/FixedUpdate functions, but e.g. OnTriggerEnter and various other functions still run.

–Eric

Huh, really ? Nice to know, thanks a lot for the info.

So there is no way to completely disable a script including these functions ?


oxl

I noticed this last night as well when going through the platformer tutorial (for the 3rd time - things are starting to click for me :slight_smile: ). I thought there was a setting I was missing.

This seems to happen with the ordinary single view too - we’re looking into it.

gameObject.SetActiveRecursively(false);

Well , thanks, now I am a bit confused.

Isn’t it the same to disable a script or setting active = false ?

Sometimes I feel lost due to console messages telling me not to use Enabled = true , but using active = true …


oxl

.active is for GameObjects only. .enabled is for components.

–Eric

ok, thank you , I think now I got it.

Setting an GameObject active = false will completely disable its attached scripts, so that they are not executing the OnCollisionEnter() etc functions anymore.


oxl

Of course, the possible downside is that the entire object and all components are deactivated. If that’s not what you want, you can add a line of code to the OnCollisionEnter() etc. functions:

function OnCollisionEnter() {
   if (!this.enabled) return;

   // rest of function...
}

That way it won’t do anything if the script is disabled.

–Eric

Is there actually a reason why it’s by design to deactivate only the Update() functions while disabling the script ?

I’m just wondering …


oxl

A typical example is AI that has a trigger with a certain radius, and is activated when the player enters the trigger, so you still want OnTriggerEnter to actually work, even though you don’t need Update() running when the player is out of range.

–Eric

Thanks Eric, much clearer now :slight_smile:


oxl