Home > Net >  error CS0246: The type or namespace name 'LoadSceneMode' could not be found (are you missi
error CS0246: The type or namespace name 'LoadSceneMode' could not be found (are you missi

Time:04-12

I'm still following a tutorial on making a 2d game in unity. I am working on the GameManager script, but I am getting a error that the namespace LoadSceneMode even though I am coping the code as the guy types it.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour
{
    public static GameManager instance;
    private void Awake()
    {
        instance = this;
    }

    // Ressources
    public List<Sprite> playerSprites;
    public List<Sprite> weaponsprites;
    public List<int> weaponPrices;
    public List<int> xpTable;

    // References
    public player player;
    // public weapon weapon..

    //Logic
    public int pesos;
    public int experience;
    

    // Save state
    /*
     * INT preferedSkin
     * INT pesos
     * INT experience
     * INT weaponLevel
     */
    public void SaveState()
    {
        string s = "";

        s  = "0"   "|";
        s  = pesos.ToString()   '|';
        s  = experience.ToString()   '|';
        s  = "0";

        PlayerPrefs.SetString("SaveState", s);
    }

    public void LoadState(Scene s, LoadSceneMode mode)
    {
        string[] data = PlayerPrefs.GetString("SaveState").Split('|');

        // Change player skin
        pesos = int.Parse(data[1]);
        experience = int.Parse(data[2]);
        // Change the weapon level


        Debug.Log("LoadState");
    }

}

I have tried re typing the script but I am still getting the same error. It said the error can be found on line (47,36)

CodePudding user response:

You need to add the UnityEngine.SceneManagement namespace to your code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
..........
  • Related