Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

SceneManager does not contain a definition for LoadScene?

Discussion in 'Scripting' started by Happy_Jingle, Feb 29, 2016.

  1. Happy_Jingle

    Happy_Jingle

    Joined:
    Mar 9, 2014
    Posts:
    103
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using UnityEngine.SceneManagement;
    5. public class MenuScript : MonoBehaviour {
    6.     public Canvas startMenu;
    7.     public Button setTeam;
    8.     public Button startGame;
    9.     // Use this for initialization
    10.     void Start () {
    11.         startMenu = startMenu.GetComponent<Canvas> ();
    12.         setTeam = setTeam.GetComponent<Button> ();
    13.         startGame = startGame.GetComponent<Button> ();
    14.     }
    15.    
    16.     // Update is called once per frame
    17.     void Update () {
    18.    
    19.     }
    20.  
    21.     public void StartGame(){
    22.         SceneManager.LoadScene (0);
    23.     }
    24. }
    25.  
    What should I do?
     
  2. johnd_unity3d

    johnd_unity3d

    Unity Technologies

    Joined:
    Jan 7, 2016
    Posts:
    1
    Can you sanity check you haven't added your own class called SceneManager?
     
  3. sysmaya

    sysmaya

    Joined:
    Nov 30, 2013
    Posts:
    16
    Code (CSharp):
    1. UnityEngine.SceneManagement.SceneManager.LoadScene( "myScene");
     
  4. rocky1138

    rocky1138

    Joined:
    Aug 13, 2012
    Posts:
    31
    This happened to me. I had downloaded an asset off the store called Falling Leaves. It included a script called SceneManager. Namespaces should be better utilized for store assets. I'll have to take a look at the code to my own to make sure I'm not breaking someone else's project unintentionally.
     
  5. AhmedAh05

    AhmedAh05

    Joined:
    Aug 10, 2018
    Posts:
    2
    I named my script SceneManager. Thanks for the solution.
     
  6. muzboz

    muzboz

    Joined:
    Aug 8, 2012
    Posts:
    93
    I just had the same problem, and I was baffled. It was because I had a project with numerous Asset Store assets in it, and one of them (XLock) did indeed have a script called SceneManager in it, which confused the whole situation.

    If you're having this problem, it's worth searching your project for "SceneManager" in case there is some other script called that.
     
  7. slampants

    slampants

    Joined:
    Oct 27, 2013
    Posts:
    7
    Got bitten by this too; had created a script called SceneManager. Thanks!
     
  8. ScionGlobe

    ScionGlobe

    Joined:
    Oct 28, 2020
    Posts:
    3
    ...

    Thank you.