Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 RamboPanda · Aug 29, 2011 at 02:43 AM · scorehighscores

How to keep Highscores?

Hello. I would like my game to be able to keep highscores but I'm not sure how to do so. I have seen some answers concerning that but I don't quite understand. Do I have to use "PlayerPrefs" to keep the score? How do I display it at the end of the game; do I have to create another scene? This is the current score scripts that I'm using.

Attached to GUI text:

 static var score : float = 0;


 function Update () 
 {
     guiText.text = "Score : " + score;
 }

This is the script to increase the score:

 var score = 0;
 
 function OnTriggerEnter (other : Collider) 
 {
     keepscore.score += 25;
     gameObject.active = false;
     Destroy(gameObject); 
 }

Thank you for your help.

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

1 Reply

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

Answer by AngryMarine · Aug 29, 2011 at 02:51 AM

I would recommend reading up on the System IO functionality of .NET which is available to UnityScript. I attached the link below. You can use it to create a file and store your high scores in, then read it back when you reopen the game and import the data.

System IO

Here's a link that helps me figure out System IO.

Unity Post for System IO

This link should help Javascript specific questions on Read and Write.

Javascript Read Write external file

Comment
Add comment · Show 7 · 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 RamboPanda · Aug 29, 2011 at 03:10 AM 0
Share

Hello. This is to use a server based highscore? How do I use it in Unity? Thank you.

avatar image AngryMarine · Aug 29, 2011 at 03:37 AM 0
Share

Nope, it can be used to write local files as you see fit. It should work with server based if that what you'd want to do but I'm not familar with that route myself. Just local stand alone work. It's a bit tough to get into but it'll work for your purposes quite well since you are trying to avoid the PlayerPrefs route.

In fact you could just create the file in windows, place it where you like and then just edit it with system IO. Simple text file should do. ;-)

avatar image RamboPanda · Aug 29, 2011 at 04:10 AM 0
Share

hahaha local stand alone is sufficient. Just needed a high score board. What kind of file should I create in windows? Possible to explain it a bit more? Simple text file like .doc? Thank you so much!!

avatar image AngryMarine · Aug 29, 2011 at 04:12 AM 0
Share

I used a simple .txt file. Under the File Class (if I remember right) you can find most of the methods you'll need to edit the file as you need. Like append, etc. A text file is really easy to check too since you can just open it up and check to see if what you were intending happens. I'm no pro so I like to keep it simple. ;-)

I just added a new link to my answer which will help make sense of the System IO and using a simple txt file! I used it myself when I was messing with System IO.

avatar image RamboPanda · Aug 29, 2011 at 07:53 AM 0
Share

Okay. Is it something like the scores will be written into the .txt file and the game will recall the last high score? I'm a bit confuse. Thank you!

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Distance and Best Distance 1 Answer

Reset highScore in Java problem 0 Answers

Highscore Save 0 Answers

Unity ignoring if statement for high score 2 Answers

my code is suppose to store high score and its storing recent score insted and it wont stop if game over and it has an score counter as well plzz help 0 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