- Home /
Unchecking a prefab's script in the Inspector doesn't "deactivate" it?
I have a prefab and a script (let's call it ScriptA) attached to it.
I have made some modifications on ScriptA and renamed the new, modified version to ScriptB.
I dragged and dropped ScriptB at the end of the prefab's component's stack in the Inspector, just under ScriptA. I want to deactivate ScriptA, so I unchecked the box next to it and left only ScriptB checked.
Things don't work as expected though. It seems as the engine does what ScriptA says (although unchecked) and only when I delete it do the new modified lines of code inside ScriptB seem to be applied.
Am I missing something here? I thought what the checkboxes where supposed to do was exactly that: activate/ deactivate some components.
It should work unless you're somehow activating or maybe requiring it through code. We ran into this early on when we forgot to delete a script.enabled = true; line from an awake function. The second headache inducing problem was that our game hierarchy was so chaotic that we realized we've modified some different lines in scriptB and as such it was perfor$$anonymous$$g similarly.
(sorry for double posting) Also, calls to that particular script will still work. For example scriptA.playXSound() called from another script will still function.
hmmm, I don't seem to have any of the issues you mentioned. What's strange is that when I hit play, the ScriptA's checkbox doesn't get checked (as a result of something activating it at runtime). Shouldn't it get checked automatically (I mean when I hit play)? Does this mean that something else is the matter and not that ScriptA gets activated?
Just saw your 2nd comment. I have other scripts calling functions in it. Thanks. Could you put that in an answer to close this? Thanks very much azzogat!
Yup, you are correct. If it's not activating by itself and you are not calling one of it's functions from another script (second comment) then unfortunately I have absolutely no idea.
Answer by azzogat · Jan 16, 2011 at 11:45 AM
Even if you uncheck a script, calling one of it's functions from another script will still work.