I have some singleton objects where I check that the static instance doesn’t exist in Awake and sets the instance, or destroys the gameObject if instance is already set. This script also sets DontDestroyOnLoad in the Start method.
What happens on some projects I use this in is the gameObject in the second scene shows up disabled, so the Update is not called on the script.
I can’t seem to find any definite answers as to why OnEnable is not being called on these objects when the scene loads.
OnEnable is only called when the MonoBehaviour’s enabled boolean is switched from false to true. This is not done automatically when a new scene is loaded, if it was already instantiated in the previous scene.
If you want to trigger something when a scene is loaded, try OnLevelWasLoaded(int level) where the int parameter is the index of the scene that was loaded. This is automatically called when a new scene is loaded, and the integer, which is the index of that level, is passed to it, so you can even check to see what scene you just changed to.