- Home /
Confused about enable
So I have a game where the pause key cannot do the easy Time.timeScale = 0 trick, as I still need the player capable of moving about the map.
But I have various yield WaitForSeconds operations going on, and I have Detonators, that I want frozen when the pause button is pressed.
So I try things like this for the Detonator:
gameObject.Find("explosion").GetComponent("Detonator").enabled = false;
And things like this for scripts that contain WaitForSeconds:
gameObject.Find("badguy").GetComponent("BadGuyActions").enabled = false;
Neither of these seem to "work". I can pause in the editor and see that yes, in fact, the Scripts are disabled, but the Detonator explosion continues to run and the yield WaitForSeconds continues to count on.
Am I misunderstanding the enable property?
If so, what can I use to stop these things during game-pause? I don't want them invisible (so I don't want to use active=false).
Thanks in advance!
Answer by Eric5h5 · Mar 05, 2011 at 12:06 AM
.enabled = false only disables behaviors like Update and OnGUI. You can make other functions check if enabled == false and stop doing whatever it is they're doing.
Well, bummer. I guess that means more code writing for me. I was hoping for an easy way to pause/resume. Thanks for the clarification!
Your answer
Follow this Question
Related Questions
Disable a script from another script 2 Answers
May I know how to reactivate an object that deactivated? 1 Answer
Detonator Issues 0 Answers
Enable or Disable Rigid Body at Runtime? 9 Answers
Turn Off/on culling mask by script? 2 Answers