- Home /
Script still runs even after i erase/remove it :(((
As the titles says... Even if i erase the script, it still keeps running the Update/LateUpdate and Start functions :S I checked with the Profiler and it steals a lot of Time ms and frames :((...
How do i stop them from working? I have it on a lot of objects and after sometime all those objects have the script removed, but they (all the scripts) still run, making the game reeeeallly slow :C
Thanks in advance ^_^!
BTW... It appears that only the scripts that are attached to Instantiated objects seem to run after removed :S
How do you "remove" them? Do you use Destroy()? You need to give more information. Show us the code which you use to destroy the script. Show some screenshots which show the gameobject in question.
Answer by ticofa · May 25, 2015 at 12:01 AM
Ok i just found out what the problem was... The problem was MY STUPIDITY XD!!!!
I had another script attaching the "script in question" on the gameobjects....
As much as i tried to erase the script from the obectjs, there was another one that was adding it again xD So to be more clear:
I was making an endless loop where the script was being removed and added, faster than the eye could see ^^! There for, I saw no script because it was being removed and added super fast, and because of that, it kept showing on the profiler and slowing the game ^^!
Thank you guys for the trouble, help AND time :'D!!!
Answer by RabidCabbage · May 24, 2015 at 11:14 PM
Are you sure you removed all references?
You could add a debug msg to the Start() method of the "removed" script that reports the host object's name & position when it loads in the scene.
Debug.Log(gameObject.name + " at " + transform.position);
Oh yeah I actually did that, but when I checked the object to see if it had the script, it didnt, but the script was still running... in fact, all the scripts were AND are running even after I removed them :S
PS: Thank you for the SUPER-$$anonymous$$EGA-HYPER-FAST Answer x'D :D!
Answer by Bunny83 · May 24, 2015 at 11:25 PM
That makes no sense. If all instances are destroyed, nothing will be executed. If you still see them in the profiler, there's still an instances somewhere. Keep in mind that you can use the search / filter field in the hierarchy view to find instances of a script.
Start is only called when you create a new instance of the script. Maybe you instantiate a prefab somewhere which has that script attached.
I know it makes no sense xD, but i double checked it throught Debug.Log, the Name and Position of the object to check if it had any script...
It didn't, but the script is still being called :S
See it here:
Your answer
