So I have an object with a script which is present on the main scene. I have another script running on the same scene and it references the object upon awake. This works fine.
However, when I switch the scene and then switch back to the main. The object just deletes itself. Hence the error. DontDestroyOnLoad didn’t do jack to solve this.
Why is this a thing. I’ve never seen this before? Why is my object just deleting itself.
Sounds like a mis-implemented singleton to me.
Marking a GameObject DDOL doesn’t prevent everything pointed to from going away. It only works that way for child objects below what is DDOL. You can only mark root objects DDOL too.
But it’s always up to you to ensure that 100% of the things pointed to by a DDOL script do not get deleted for any reason, such as a scene change.
I’ll move your post to the scripting forum where it belongs. This is the 2D forum related to posts about 2D.