dontDestroyOnLoad doesn't work as expected with scene navigation
Hi, I am a unity nab and I can't figure out this strange behaviour i have in my test game while using dontDestroyOnLoad
.
I have a __preloadScene
that is my very first scene that gets loaded in the game. It only has to load my GameSparksManager
script inside an empty GameObject
that needs to be a singletone that never gets destroyed.
My GameSparksManager
singletone script is this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameSparksManager : MonoBehaviour {
public static GameSparksManager instance = null;
void Start() {
Debug.Log ("ciao");
SceneManager.LoadScene("Auth Scene", LoadSceneMode.Additive);
}
private void Awake()
{
if(instance == null)
{
instance = this;
DontDestroyOnLoad(this.gameObject);
} else
{
Destroy(this.gameObject);
}
}
}
But what happen is that when you move between scenes the stuff inside them doesn't get destroyed, here an example video:
what am i doing wrong? thanks for your help
Your answer
Follow this Question
Related Questions
How do I keep a scene altered after the player leaves the scene and then comes back? 0 Answers
garbage collection in between scene changes? 2 Answers
Restarted scene not working properly 0 Answers
Level Selection Menu...Preview Scene 1 Answer
SceneManager.LoadScene is crashing or freezing for Android Devices 3 Answers