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 Random Binaries · Apr 05, 2012 at 12:10 PM · javascriptarrayplayerprefsarraysrecording

How do to you save time for each player and display it?

Hey guys. Can anyone help me please with this problem I'm having? I want to be able to record the time it takes for each player to complete my game and display it with the times from the other players. Kind of like a leader board. Currently my game will record and store all the times from the previous players as well as the current gamer. The problem exist when I come to display all the times from the people that played my game. As when it does display it overwrites the previous time that was being displayed. Here is my snippet of code:

var SavedTIME2COMPLETEgame;

static var displaySTRING;

function Update () {

         if(Input.GetKeyDown("o") && Dist_To_COMPLETELEVEL < 2){
             
             STOPtime = false;
             Application.LoadLevel("Completed Level Thirty Seconds");
             //SavedTIME2COMPLETEgame(timeRemaining);
             SavedTIME2COMPLETEgame = timeRemaining.ToString();
             //PlayerPrefs.SetString("", );
             //displaySTRING = PlayerPrefs.GetString("", timeRemaining);
             print(SavedTIME2COMPLETEgame);
             SavedTime(SavedTIME2COMPLETEgame);
             //Display_Recorded_Time(SavedTIME2COMPLETEgame);
             //DontDestroyOnLoad(GameManager2);
         
         }
 }
 
 function SavedTime(SavedTIME2COMPLETEgame : String) {
 
     displaySTRING = PlayerPrefs.GetString("", SavedTIME2COMPLETEgame);
     Debug.Log(displaySTRING);
 
 }

The above piece of code is from my main game scene. The following piece is from the complete level/game scene:

function OnGUI () {

 GUI.Label(new Rect (10, 10, 100, 100), "Time Recorded: " +GameManager2.displaySTRING);

}

Help much appreciated. Thank you.

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 randombinaries · Apr 05, 2012 at 03:39 PM

Anyone know the answer to my problem please?

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 Owen-Reynolds · Apr 05, 2012 at 02:39 PM

You only have a single "print" command --`GUI.Label`, so of course it will only ever display one thing.

If you want to show 4 times, you need four variables and 4 prints. If you know how to use arrays, then have display string be a size 4 array, or else just make displayString2, 3 , 4. Probably easiest to put playerX's score in displayStringX. Then have 4 GUI.Labels with "if not empty string" in front of each.

Comment
Add comment · Show 2 · 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 randombinaries · Apr 05, 2012 at 02:45 PM 0
Share

Can you give me a example using arrays of how I could display four things using the above example please?

avatar image cregox · Apr 05, 2012 at 02:51 PM 0
Share

@random if you're willing to finish your game, you're better off finding that kind of example on your own.

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

Distance error: Cannot cast from source type to destination 0 Answers

displaying playerprefs 1 Answer

getting "null" when using array. (javascript) 1 Answer

Is there a decent tutorial for a local high score table (android)? 1 Answer

Loading with ArrayPrefs 1 Answer


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