0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MenuButton : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
    }

    public void LoadScene(string sceneName)
    {
        // this line below isn't recognized even if scene management is mentioned above
        SceneManager.LoadScene(sceneName)
    }
}

I saw a few Youtube videos and nothing works, also when I write using, it doesn't show unity suggestion nor scene management suggestions.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Is this a visual studio specific problem? Does unity throw an error when it tries to compile? – SupaMaggie70 b Mar 13 '23 at 16:01
  • 1
    You're missing a `;` at the end of it for one. But what exactly do you mean by "isn't recognized"? There is no syntax highlighting? There is no autocomplete? All seems fine, but it never gets called? It gets called but doesn't actually load the scene? – Bart Mar 13 '23 at 19:32

2 Answers2

0

I have seen some people creating a script called "SceneManager.cs", and this is mostly causing this issue, since it has the same name, but different namespace.

lulasz
  • 1
  • 3
0

This should be a syntax error.

As Bart said, you are missing the statement closing symbol ;.

Try the code below:

public void LoadScene(string sceneName)
    {    
        SceneManager.LoadScene(sceneName);
    }

If programming in VS, you should be able to use ALT+ENTER to take quick suggestions to fix some errors.

Jiale Xue - MSFT
  • 3,560
  • 1
  • 6
  • 21