Question by
dominic311dj · Mar 19, 2020 at 10:27 AM ·
buttonscenescene-loadingscene-switchingscene-change
Why is my scene not loading?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoadAScene : MonoBehaviour
{
public int SceneToLoad = 0;
public void GoToScene()
{
SceneManager.LoadScene(SceneToLoad);
Debug.Log("Clicked");
}
}
This script is called by pressing a button, and it works in one scene but not another scene where I need to use it. I copy and pasted the button and it doesn't work. Please help.
Comment
Answer by Tinx-Development · Jun 12, 2020 at 08:41 PM
i think u need an name and no int like this
public string scenenametoLoad;
public void GoToScene()
{
SceneManager.LoadScene(scenenametoLoad);
}
LoadScene
can also take an integer.
Answer by Gamefal1820 · Aug 09, 2021 at 10:13 AM
Did you add that scene in Build Settings? If not so, then add it
Your answer
Follow this Question
Related Questions
When I load a scene a second time, some objects don't show up 0 Answers
changing scene not working? 0 Answers
Game crashes after button is clicked to load scene 0 Answers
How do i create a scene variable? 3 Answers