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 /
  • Help Room /
avatar image
0
Question by Manu_Kumar · Dec 20, 2015 at 03:23 PM · savingpointsscores

Problem in Saving Score?

Hey guys I have a game in which we have to pop bubbles and score points....And I have another scene in which I display the high score... And then each time the player score which is higher than the previous high score,... it gets updated....

And now the problem is How can I save that high score..?

This is the script which handles the currentScore.

using UnityEngine; using UnityEngine.UI; using System.Collections;

public class ScoreHandler : MonoBehaviour { public static int currentScore;

 // Use this for initialization
 void Start () {

 }
 
 // Update is called once per frame
 void Update () {
     gameObject.GetComponent<Text> ().text = "score : "+currentScore;

     if (currentScore >= HighScore.highscore) {
         HighScore.highscore = currentScore;
     }

 }

}

//////////////////////////and this script handles the high score...

using UnityEngine; using UnityEngine.UI; using System.Collections;

public class HighScore : MonoBehaviour { public static int highscore; // Use this for initialization void Start () { }

 // Update is called once per frame
 void Update () {
         gameObject.GetComponent<Text> ().text = "high score : "+highscore;
 }

}

both the text elements are UI text elements which are in the Canvas.

Soo,... How I can Save that high score..?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Sageose · Dec 20, 2015 at 07:10 PM

So is the issue saving it between scenes or between versions/new installations of the game?

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
avatar image
0

Answer by LazyElephant · Dec 20, 2015 at 08:02 PM

You can save a high score using PlayerPrefs as shown in this question. http://answers.unity3d.com/questions/726178/how-do-i-use-playerprefs-to-save-my-score.html.

Alternatively, you could save it to a file. Both of these options are talked about in this live training session http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loading?playlist=17117

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 Sageose · Dec 20, 2015 at 08:06 PM 0
Share

Yes you can use Playerprefs but they aren't encrypted and can be modified unless you encrypt them with some script.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

spawn object every 10 score points 1 Answer

How to save many instantiated objects position/rotation at runtime??? 2 Answers

Is there a way to save a scene in a current state? 0 Answers

Saving the State of Text in an Array 0 Answers

Save and Load data from a Scriptableobject 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