|
Just wondering about how GameObject.active works? Currently I have a small demo using the first person controller prefab where I can walk around a room. If I set the first person controller object's active member to false it still seems to be running the MouseLook script. All other scripts attached to the object appear to be disabled. Has anyone else had this problem? I tried pulling out the MouseLook script and deactivating it directly by going GetComponent().enabled = false but that didn't seem to work. I'm pretty sure there are no other instances of the script running. Any Ideas? Thanks
(comments are locked)
|
|
Hi, Look for
This is maybe what you need. Bye, Jean
(comments are locked)
|
GameObject.active disables or enables scripts and components running on the game object as well as making it not appear in most object searches such as GameObject.FindWithTag while disabled.
I don't know if there are certain scripts that can be run while it is disabled, I dont think so but for the sake of completeness See note about MonoBehaviours enable.
For just hiding the object: http://answers.unity3d.com/questions/14165/show-and-hide-a-prefab-or-gameobject.html
Sep 06 '11 at 06:03 PM
Cawas
OnCollision() still runs when a script is disabled, I believe
Apr 04 '12 at 11:16 PM
cowlinator
(comments are locked)
|
|
SetActiveRecursively sets the whole game object to the defined state... but gameObject.active will only turn the parent on and the children will be in their previous state only thats what ur prob. is!
(comments are locked)
|

sorry there are actually 2 instances of the script. One on the capsule and one on the camera. But shouldn't setting its active member to false should deactivate all of the children?