• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by alexay007 · Apr 24, 2017 at 08:52 PM · beginnerscore systemleaderboardscoreboardunity 4.5

I need a leaderboard

I'm making a Sniper type game and I already have a score manager script:

 using UnityEngine;
 using System.Collections;
 
 public class ScoreManager : MonoBehaviour {
 
     public GUISkin skin;
     public int Score;
     public float BestDistance;
     private float lastestDistance;
     private float timeTemp = 0;
     private bool showdistance = false;
     private int scorePlus = 0;
     
     void Start () {
         Score = 0;
         BestDistance = 0;
     }
 
     void Update () {
         if(showdistance){
             if(Time.time >= timeTemp + 3){
                 showdistance = false;    
             }
         }
     }
     
     public void AddScore(int score,float distance){
         int bonus = 1;
         
         if(distance>500)
             bonus = 2;
         
         if(distance>1000)
             bonus = 5;
         
         if(distance>1500)
             bonus = 10;
         
         scorePlus = score * (((int)(distance * 0.1) + 1)) * bonus;
         Score += scorePlus;
         lastestDistance = distance;
         if(distance>BestDistance){
             BestDistance = distance;
         }
         
         showdistance = true;
         timeTemp = Time.time;
     }
     
     void OnGUI(){
         if(skin){
             GUI.skin = skin;
         }
         GUI.skin.label.fontSize = 35;
         GUI.skin.label.normal.textColor = Color.black;
         GUI.skin.label.alignment = TextAnchor.MiddleLeft;
         GUI.Label(new Rect(20,20,300,40),"SCORE "+Score);
         GUI.skin.label.fontSize = 20;
         GUI.Label(new Rect(20,60,300,40),"BEST "+Mathf.Floor(BestDistance)+" M.");
         
         if(showdistance){
             GUI.skin.label.fontSize = 35;
             GUI.skin.label.alignment = TextAnchor.MiddleCenter;
             GUI.Label(new Rect((Screen.width * 0.5f) - 150,(Screen.height*0.5f)-50,300,100),Mathf.Floor(lastestDistance)+" M.\n+"+scorePlus);
         }
     }
 }

but what i want is a leaderboard scene where the bests scores are shown. Some idea?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

102 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to save playerscore on a list 0 Answers

How to have a scoreboard system through multiple objects? 0 Answers

show score and keep score on screen until start new game? 0 Answers

Problem with counting score in 3D game 1 Answer

Google Play Games Services - Wrong scores, Traffic mostly Redirection (3xx) 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges