- Home /
Scripts still functioning even if UN-checked in editor?
Anyone else finding some strange bugs with unity 3.2? i searched the forums a bit and didn't find much...
My main "strange" occurrence is when I un-check a script on an object, but the script still runs. I'm running into other errors that "should" be working correctly, and I'm wondering if there are other buggy things that you guys might know about. any help is greatly appreciated!
function populateGrid() { for(i= 0; i < boxCount; i++){ identifier = Random.Range(0,4);
switch(identifier){
case(0):
(asset0.GetComponent(touchingThreeScore) as touchingThreeScore).idNumber = 0;
myAsset = (Instantiate(asset0, Vector3(transform.position.x + xAdjust, transform.position.y + yAdjust, transform.position.z), transform.rotation) as GameObject);
break;
case(1):
(asset1.GetComponent(touchingThreeScore) as touchingThreeScore).idNumber = 1;
myAsset = (Instantiate(asset1, Vector3(transform.position.x + xAdjust, transform.position.y + yAdjust, transform.position.z), transform.rotation) as GameObject);
break;
case(2):
(asset2.GetComponent(touchingThreeScore) as touchingThreeScore).idNumber = 2;
myAsset = (Instantiate(asset2, Vector3(transform.position.x + xAdjust, transform.position.y + yAdjust, transform.position.z), transform.rotation) as GameObject);
break;
case(3):
(asset3.GetComponent(touchingThreeScore) as touchingThreeScore).idNumber = 3;
myAsset = (Instantiate(asset3, Vector3(transform.position.x + xAdjust, transform.position.y + yAdjust, transform.position.z), transform.rotation) as GameObject);
break;
}
if(xAdjust < columns){ xAdjust += 1.1; }else{ xAdjust = 0.0; yAdjust -= 1.1; }
var touchingThreeScript2 : touchingThreeScore = (FindObjectOfType(touchingThreeScore) as touchingThreeScore); touchingThreeScript2.shouldPlay_tts = true;
}
what is still running? If you disable a script, only Update, LateUpdate and FixedUpdate functions will be disabled. Other events should fire normally. What "other errors"? There is almost nothing "buggy" maybe you just don't know how it works. Please ask specific questions! Post your code if something don't work and explain what is not working. Please read the FAQ: http://answers.unity3d.com/faq
I appologize for not giving more explicit information. The best i can describe is that my creator script, (which instantiates a bunch of cubes currently) still runs even if i UNcheck the box next to the game object who carries the script. I've added the script info to the original question.
This behavior is as described in the docs and is not buggy.
Answer by · Feb 14, 2011 at 05:38 AM
As Bunny83 says, the other functions will still work if they're specifically called.
You could add something like this to the top of your function:
if ( gameObject.active == false )
return;
OH WOW.. thank's for this.. I am pretty new to unity and this confused me alot.
I am building a small 2D multiplayer tank shooter for fun with the photon cloud. I was really surprised when I realised that the OnTriggerEnter2D in one of my deactivated scripts was still being called. It took me some time to figure that out >.<