- Home /
How do i make a score system in the main menu.
I have a score system for my other levels(or scenes) I just don't know how to too get all the point from the other scenes and put them in this scene (or main menu) and use it to buy stuff. I've been trying to figure it out for the past couple of days but haven't got anything yet.
this is what my main menu looks like: obviously I still need to work on my design and the way it works is where if you press a button the camera pans to the desired position. As you can see I still have a lot of button and panel designing. Here's what I'm talking about: As you can see the Label of the top right corner is the coin holder. I'm trying to make a script to where it grabs the coins from other scenes and puts it in this one and I haven't had anything work yet. if anyone know how to do what I want it to do then please let me know or show the script... Anything helps. :) thanks.
PlayerPrefs would work. Just save your points to that and then retrieve them from main menuscene. Or have an empty Gameobject with your score manager script on it and a donotdestroyonload command so it will get passed on from scene to scene with values
Answer by Ginxx009 · Dec 11, 2017 at 06:47 AM
You can do it by PlayerPrefs.getInt();
so it's something like this.
PlayerPrefs.GetInt("Score", PlayerPrefs.GetInt("Score") + 1); //just change the 1 value there to another key of the playerprefs so that you will get all the scrores from all your loadlevels
Hope it can help you :)
how would I put this in a script tho. Sorry I'm new to coding.
as @Paul$$anonymous$$evin said you can use playerPrefs .it saves your data in registery I think :).
for example it's your score system
public int Score;
public void addScore(int score){
Score+=score;
playerPrefs.setInt("SCORE",Score);//so it will save SCORE in registery I guess :)
}
and how to use it again
in main menu
public int score;
void Start(){
score=playerPrefs.getInt("SCORE");//it will put the value of SCORE in score.
}
I made 2 scripts of both of theses but they both say they have errors on the playerprefs. is like a variable names? what is it?
Your answer
Follow this Question
Related Questions
One scene, many levels?? 2 Answers
Points system for unity 1 Answer
Is there another way of counting Scores (points) instead of Colliding (destroying) ?? 1 Answer
Fade In each level 1 Answer
Add Score for every Object inside a Box 2 Answers