Script enable disable doesn't work

I am making a game in which the script enable/disable button has no effect. The script remains active. Is this a bug in my project and should I start from scratch or is there something I don’t know about this?

Andy

27038--993--$picture_1_597.png

Yes, I’ve noticed that too. It seems to apply to more than scripts. Incidentally does the texture offset function in the inspector work for you?
AC

I haven’t used it recently but with Unity 1.5 I did notice the offset did not work always.

Andy

It does work to enable/disable scripts, but not all functions are actually disabled. Primarily trigger functions I believe, so you can turn off scripts for stuff that’s not needed, but triggers will still work so they can be “woken up”. Since you have mouseover stuff, I guess that’s what’s happening. (And yes, the texture offsets work fine here…)

–Eric

That is interesting. I am trying to make an object change color by moving a mouse over it and then after a click on the object switch to making a different object change color by moving a mouse over it. Is there any way to completely disable a script like this one in one object and enable the same script in another object?

function OnMouseEnter () {
renderer.material.color = Color.yellow;
}

function OnMouseExit () {
renderer.material.color = Color.blue;
}

The enabled property only enables/disables Update and FixedUpdate. See:MonoBehaviour.enabled

But you are free to inspect the value yourself.

function OnMouseEnter() {
   // Do nothing unless enabled
   if ( ! enabled ) return; 

   // ... else continue as normal

   ...
}

Hey it worked, thanks a lot.

Andy