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 Dogg · Jan 14, 2015 at 11:39 AM · c#gameobjectsceneplayerprefs

How Do You Have Multiple High Scores For 1 GameOverScene?

So I have multiple levels, each with their own PlayerPrefs that saves the Player's score when they die. After they die they are taken to a GameOver scene that shows them their score. The problem is that the GameOver Scene only loads the first level's score because it only has one script that does that. What I want to know, is how can I after or before the player dies, disable the game object or script of the first high score in the GameOver scene, and then enable a game object or script that shows the high score depending on the level I'm in(In the GameOver Scene). I hope I'm making sense.

In concept I think it would go something like this: First I create an array of game objects, and when a certain scene is loaded, enable a certain game object. But how can that work? Through prefabs maybe?

By the way, I could always just create a bunch of GameOver scenes for each level, but that would be laziness on my part big time(unless it recommend which I highly doubt).

Comment
Add comment · Show 2
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 pako · Jan 14, 2015 at 01:14 PM 0
Share

In an effort to help you, I'll just say these for your consideration:

I understand that you want to have a GameOver scene that will show the High Scores for each level the player has played. However, most things you say just don't make sense, and/or the way you are planning to do things is not "Best Practice". For instance:

  1. Why have multiple PlayerPrefs? why can't each level save the high score with a different name, in the same PlayerPrefs? e.g. HighScore1 corresponding to level 1, HighScore2 corresponding to level 2, etc.

  2. Why have a script in the GameOver Scene that only loads the first level's score? Why can't a single script load all High Scores?

  3. Why have multiple GameOver Scenes?

  4. If you want to know how to enable or disable GameObjects you should reference the documentation:

http://docs.unity3d.com/ScriptReference/GameObject.SetActive.html

avatar image Dogg · Jan 14, 2015 at 10:03 PM 0
Share

Thanks for your reply. I'll answer your questions now:

  1. If I understand you correctly, then that's because I want to be able to go to a scores menu and see all the different scores I have on each level. Every time I get a higher score than before, it overwrites the previous score. I guess you can say it's because of the way my PlayerPrefs is set up/inexperience that stops me from using just one Player Prefs. I'm talking about Player Prefs set integers by the way.

  2. I don't know how to load all high scores. Probably something like PlayerPrefs get all int or something.

  3. That was just a thought. I do not plan on having multiple GameOver scenes.

  4. Thank you but I already know how to do that. I was asking if I can activate game objects from a different scene.

1 Reply

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

Answer by MKayJay · Jan 14, 2015 at 11:06 PM

If you're comfortable working with arrays, you might want to consider using PlayerPrefsX. It's an extension to playerPrefs that allows you to save arrays. You can find it here where you can simply copy/paste the code from and then use that class to handle your PlayerPrefs. I use that for my current project. This way you can have an entire array for each level, or use the entire array to store the score from all the levels. Personally I find it much easier to handle a lot of highscores and stuff with arrays.

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 Dogg · Jan 15, 2015 at 01:39 AM 0
Share

Wow looks complicated because the short explanation is in JavaScript, but thank you for the post. I'll see if I can intergrade it properly. Thanks again.

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

26 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

Related Questions

c# destroy gameobject on 0 hp 2 Answers

Nullreferencexception using PlayerPrefs.GetInt and GetString 1 Answer

How to Load PlayerPrefs from a different scene 1 Answer

Readd GameObject to scene (to restore it) 0 Answers

Unity 3d(Space) Questions 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