Search Unity

Bug SceneManagement does not exist in the namespace 'UnityEngine'

Discussion in 'Editor & General Support' started by WagnerDav, Jul 6, 2020.

  1. WagnerDav

    WagnerDav

    Joined:
    Jul 6, 2020
    Posts:
    12
    First of all! Sorry for my English

    I have this simple script:

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.SceneManagement;
    6.  
    7. public class NextLevelPoint : MonoBehaviour
    8. {
    9.   public string lvlName;
    10.   void OnCollisionEnter2D(Collision2D collision)
    11.     {
    12.        
    13.        if(collision.gameObject.tag == "Player")
    14.        {
    15.            SceneManager.LoadScene(lvlName);
    16.        }
    17.     }
    18. }
    19.  
    When I tried to compile it showed the following error:

    The name 'scenemanager' does not exist in the current context


    Trying to solve the problem I restarted Unity and modified the code to test the scene object. But when I went back to the code I showed earlier it stopped showing the error and run the game.

    Could it be that Unity is unable to start the library as soon as it is called so when I restarted it managed to run the code?


    I'm using VScode to write the code, could it be it too?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Is your error showing in Unity or just VS Code?
     
  3. WagnerDav

    WagnerDav

    Joined:
    Jul 6, 2020
    Posts:
    12
    On Unity.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'm guessing you originally had the capitalization wrong. It is correct in your code now, but if that is how it was written when you received this error it would have instead said:
    That is because in C# getting capitalization wrong is the same as getting spelling wrong.

    If my guess is wrong, please post the exact error message, copy and pasted.
     
  5. WagnerDav

    WagnerDav

    Joined:
    Jul 6, 2020
    Posts:
    12
    Sorry I wrote the wrong title.
    I was reading about the error in the title and I didn't see that I wrote it instead of what I wanted.


    The error is:

    The name 'SceneManager' does not exist in the current context