I’m working on a game where some singletons are present between scenes. However, other singletons are different in each scene so I don’t use DontDestroyOnLoad method for these.
The problem I found is that the game object that contains the singleton is destroyed in an arbitrary order (checked by debug logs in the console). I can change the script execution order in the project settings but this seems not to work with OnDestroy and OnDisable events.
Discovered the same issue. It’s a bummer OnDestroy doesn’t respect script execution order.
Couldn’t find a way to set the order. Instead, discovered a way to deal with not knowing the order. I ended up creating a public static bool called WasDestroyed inside of the singleton class to track OnDestroy. WasDestroyed’s value is set when the singleton calls its OnDestroy. Then I could check WasDestroyed in other scripts OnDestroy to see if I should be accessing the instance or not.