I'm trying to use a singleton to save the players score they just got and pass it to the next scene, but I'm getting an error: Inaccessible due its protection level
.
public class Score : MonoBehaviour
{
public static Score instance { get; private set;}
public int score = 0;
void Awake()
{
InvokeRepeating("increaseScore", 1, 1);
}
void Update()
{
score++;
// Set the score text.
guiText.text = "Score: " + score;
instance = this;
}
}
That's the code for where the playing happens in scene 1.
public class endScore : MonoBehaviour
{
void getScore()
{
Score.instance.Update();
}
}
This is where I'm calling it in the next scene.
EDIT:
public class endScore : MonoBehaviour { void getScore() { Score.instance.Update(); guiText.text = "Score: " + score; } }
It does'nt recognise the + score
? I thought singletons grabbed all the variables from the set instance?