Script being run even with no objects in scene.

Hi,

I’m recently encountered an issue where it seemed as though one of my MonoBehavior scripts were being called (Awake,Start) even when there were no objects that had the script attached. I tried removed ALL objects from the scene (deleting them), yet script was still being called. Is this some sort of project file corruption?

Thanks!

Hi,

without knowing your script or project, it could be that you are using ExecuteInEditMode or @script ExecuteInEditMode() (JS) in your script.

In that case some functions will be called while working in the editor.

Have a loot at:

Hope this helps.

Greets

Alex

Is it being called in play mode or when you are actually starting the built game? Make a backup of the script in a location other than your assets folder then delete the script from your assets folder, then when you start play mode from the unity editor check the console window and hopefully wherever the script is being called from should throw an error.

Make also sure this isn’t caused by any DontDestroyOnLoad() that you might have somewhere else in your project.

Also check your camera or other objects if they accidentally have the script on them.

And as tanoshimi commented, make sure you are not chasing a ghost. Use Debug.Log() to output the gameObjects name or something like that to track it down.

@oscarhou I realise this question if from the mists of time, however do you recall if you ever find a solution? I am seeing the same issue (the Start() method of a script being called when not in the scene), and have ruled out all of the possibilities mentioned above.