- Home /
Disabled Script still does OnMouseDown
Hi,
I have a script with two functions in it, an Update and an OnMouseDown.
When I disable it, the code in the Update no longer runs, but the code in the OnMouseDown is still working.
Is this by design? And if so, why?
thanks
Answer by Eric5h5 · Jun 15, 2010 at 06:27 PM
Disabling a script only disables Update and similar functions (including OnGUI), but not much else. This is by design; it's not a bug. That way you can prevent scripts from using CPU time with Update when not needed, but use other functions to re-enable them or perform other functions if necessary.
If you need other functions aside from Update etc. to be disabled too, use this code:
function OnMouseDown () {
if (!enabled) return;
// rest of code
}
This is still relevant eight years later. This saved me a lot of headache!!! Thank you!!
Your answer
Follow this Question
Related Questions
Disable SCRIPT HELP!!!! 1 Answer
How do I disable a wind zone through script? 2 Answers
Turn Off/on culling mask by script? 2 Answers
disable/enable mouselook not working? 1 Answer
Script Not staying disabled 2 Answers