I have created a GameObject with this function to be passed to the next Scene. However when i go back to that scene, it duplicates the GameObject.
How do i do fix that? (sorry for my english)
I have created a GameObject with this function to be passed to the next Scene. However when i go back to that scene, it duplicates the GameObject.
How do i do fix that? (sorry for my english)
Its normal behaviour for DontDestroyOnLoad. What happens is instance of the object is moved between scenes and when You come back unity still creates new object as it suppose to be there. This is why You end up with two objects.
What You have to do is when new scene is loaded You have to check if object You moving is only instance of that object and destroy other instances that might have been created.