Its my first time asking a question here. I started programming in UNITY 3D just recently, so my question can be very common, but I really can't find any answers for it. I'm doing a tutorial from the YouTube and coping the same code, everything is the same as in video, but the author don't have any problems with it, while I have, I checked the code 10 times, here is it and the problem is in title. Thank you in advance for your support!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public static GameManager instance;
private void Awake()
{
instance = this;
}
// Resourses
public List<Sprite> playerSprites;
public List<Sprite> weaponSprites;
public List<int> weaponPrices;
public List<int> xpTable;
// References
public Player player;
//private weapon weapon...
//Logic
public int pesos;
public int experience;
// SaveState
/*
* 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)
{
if(!PlayerPrefs.HasKey("SaveState"))
{
return;
}
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");
}
}
CodePudding user response:
Scene is apart of the the SceneManagment namespace. Try adding:
using UnityEngine.SceneManagement;
source: https://docs.unity3d.com/ScriptReference/SceneManagement.Scene.html
CodePudding user response:
I think there is a problem with your script name. public class GameManager : MonoBehaviour Check your script name, Your script name should be GameManager or should be matched with the public class.
CodePudding user response:
You are missing a package reference. A google search tells me that Scene
class is implemented in UnityEngine.CoreModule
so try adding it at the top:
using UnityEngine.CoreModule
If you are using Visual Studio you can place the cursor on Scene
and hit crtl
.
for suggestions.