- Home /
How to switch between scenes?
I have Unity 2017.2.0. In old versions This works
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ButtonManager : MonoBehaviour {
public void econombut (string newGameLevel)
{
SceneManager.LoadScene (newGameLevel);
}
And this is also not working
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ButtonManager2 : MonoBehaviour {
public void econombut ()
{
SceneManager.LoadScene (1);
}
But now non of this codes are working and I dont know how to switch scene. I want to click a button called "econombut" and then go to Scene "1". But now in "On clock" is no functions like before. P.S. I allready add scenes in build settings, but is still doent work like before.
Also i look a lot of videos in YouTube and they doesnt help because they use old codes. Please help me
Something else must be the problem, because that's exactly how you load a scene from a script.
What errors do you receive? Or what is the actual behaviour?
$$anonymous$$aybe you did not assign the eonombut()
function to the OnButtonClick event of your button?
Ok, how is your button set up? Send screenshot of the button selected and what the inspector shows, and another one showing all the functions the "On Click" component shows, please. It'll be easier to understand what's going on.
Hello there,
First, try putting Debug.Log("YourFunctionName") before or after the scene loading line. There's nothing wrong with your code, so I can only assume the function isn't getting called properly.
Hope that helps! Cheers,
~LegendBacon
@OkeyNik Try to use LoadSceneAsync.
Scene$$anonymous$$anager.LoadSceneAsync("SceneName");
Your answer
![](https://koobas.hobune.stream/wayback/20220612151324im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Does anyone know how to look into this sort of thing? (Desciption) 3 Answers
Re-loading a scene but on the background older scenes are displayed 1 Answer
(2D) Can't make a scene transition between 2 game objects colliding - 2019 1 Answer
How to make this scene changing? 1 Answer
UnloadSceneAsync() does not seem to work with additive scenes. 1 Answer