On my project when I have load a new scene with
SceneManager.LoadScene("Preview",LoadSceneMode.Single);
the canvas from previous scene stays on scene and the canvas on the new scene (Preview in this case) is in front of it and the Game Objects I have created in a scripts Start() is cannot be seen.
I don’t want the previous scene’s canvas to be seen at all, but couldn’t manage to do that. How can I fix this?
Thanks in advance.
Seems like your canvas is DontDestroyOnLoad.
Here is a thread discussing undoing DontDestroyOnLoad: Undo DontDestroyOnLoad? - Questions & Answers - Unity Discussions
One option could be attaching a script something like this to the object you don’t want to carry on to the next scene:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
private void OnLevelWasLoaded(int level)
{
Destroy(gameObject);
}
}
I haven’t tried the code but it should destroy what ever object the script is attached to when you change the scene.