Fader stays active

Hi guys! So I just finished this video and i realised that my fader won’t go away… so I thought there is something wrong with my code, and copied the codes from the lecture’s file… but I still have the same issue, and that is: " DontDestroyOnLoad only works for root GameObjects or components on root GameObjects." Which i do not understand why the Portal script is saying this… I attached this script to my portal game object and I still get this message… weird

Unity is trying to tell you that the Portal is a child object of another GameObject. For example, you might have a GameObject named Portals with all of the Portals as children of that object.
The issue is that DontDestroyOnLoad can’t move that portal into the DontDestroyOnLoad scene because it’s not at the root. Just make sure your Portals have no parent.

1 Like

So I fixed that, it was silly from me. Tho, after fixing that I stumbled upon a next error that popped out which says: “MissingReferenceException: The Object of the type “SavingWrapper” has been destroyed but you are still trying to access it.” weird, and this is coming from the saving wrapper script, which is in fact in the scene as a gameobject

This happens when there is an existing SavingWrapper within the scene (when the game is not running). The Saving Wrapper should only be in the PersistentObjectPrefab.
Often this is caused by leaving the prefab in the scene after creating the prefab.

When you call FindObjectOfType, the first instance found is what is returned. If there is a SavingWrapper within the scene, it is found instead of the one in the DontDestroyOnLoad scene. Then when we change scenes, the SavingWrapper found in the scene heirarchy is destroyed and the reference yields the MissingReferenceException

1 Like

oh my god it was in the hierarchy and i thought it needed it to be there in order to work… damn… you are a life saver.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms