Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by hans_vesthardt98 · Jun 15, 2013 at 04:51 PM · c#guiscore

How can i make a local high score system with C#?

EDIT:

Hi, how can i make a local high score system? I want this to work so it saves my score IF it's higher than my last high score. How can i do that?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by hans_vesthardt98 · Jun 19, 2013 at 06:42 PM

Hey guys, i made a local high score system myself based on my players z position. Hope this will help you if you want the same:

         void Update () {
             if ( transform.position.z > PlayerPrefs.GetInt ("highScore") ){
                 PlayerPrefs.SetInt ("highScore", Mathf.RoundToInt (transform.position.z ) );
             }
         }

And then here is the GUI.Box which shows me my current score (my z position) and my highest score.

      void OnGUI() {
         GUI.Box ( new Rect ( Screen.width-150, 0, 150, 50 ),"Score: " + Mathf.RoundToInt (transform.position.z) + "\n High Score: " + PlayerPrefs.GetInt("highScore") );
     }


If you have any questions about the system, please, just ask!

Cheers

Comment
Add comment · Show 1 · Share
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
avatar image mike1233 · Feb 06, 2017 at 10:33 PM 0
Share

does this work for 2d game? please let me know

avatar image
0

Answer by rhbrr5hrfgdfgw · Jun 15, 2013 at 05:03 PM

I didn't understand your question, do you want it to show your score? thats it? if so add a new variable called score or something var score : int = 0; and then call the score variable here GUI.Box ( new Rect ( Screen.width-150, 0, 150, 50 ),"Score: "+score); thats it?

Comment
Add comment · Show 1 · Share
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
avatar image hans_vesthardt98 · Jun 15, 2013 at 05:05 PM 0
Share

No my question is how i can make a local high score system so on the top line of my box i have my score, that's working, and on the bottum line it says: High Score: xxx. So i want something that saves my score and shows my highest score ever in my GUI.Box

avatar image
0

Answer by Pyrotechnic · Feb 07, 2017 at 08:43 AM

set it up so when you die or finish a round the score is compared to the highscore, then if it is higher set a variable called highscore equal to the score. Then save it using playerPerfs or dontdestroy on load. If you need exact scripts just ask.

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Score display not working 1 Answer

Make a custom score counter in unity with c# 1 Answer

Displaying score on screen in specific place 1 Answer

Trying to get this coin system to work to no avail 1 Answer

Adding score when enemy dies (Errors) 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges