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 Kalzong · Mar 12, 2014 at 12:19 PM · timeplayerprefsdatabase

Save gamedata to database (playerprefs)

Hi!

I have a little project doing a 2d game in Unity. My game idea is to complete the level as fast as you can. I have accomplish the time label in to the game but i don´t know how to save it in to a database. I have seen people using playerprefs.

Is that something I should use?

My next question is if I can use somekind of database to store my timescore? I have limited knowledge about sql server.

I would be grateful for answers :)

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
3

Answer by TonyLi · Mar 12, 2014 at 02:35 PM

PlayerPrefs is designed to save small amounts of data locally. It's ideal for saving game settings (e.g., audio volume, key bindings, etc.) and high scores. Example:

 void SaveTimescore(string timescore) {
     PlayerPrefs.SetString("Time Score", timescore);
 }
 
 string GetTimescore() {
     return PlayerPrefs.GetString("Time Score");
 }

In Windows, this data is in a registry entry that's only supposed to be accessed through a Unity application. Since you want to store it in MS SQL Server, you can use this "Beginner's guide to accessing SQL Server through C#" tutorial in your Unity app and your MVC app.

Comment
Add comment · Show 4 · 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 livevlad · Mar 12, 2014 at 03:49 PM 0
Share

Do you really think high score should be in player's preference ? I mean if you have a game of 100 different levels with a high score for each one.

I am interesting in your point of view.

avatar image TonyLi · Mar 12, 2014 at 04:02 PM 0
Share

Why not? 100 scores isn't a lot of data. It really just depends on the game. If you only need to save a small amount of data locally, it's a quick and easy cross-platform method. If you want to $$anonymous$$imize the number of entries in PlayerPrefs you can store everything in one string -- for example, using a comma-separated string of scores, or serializing to JSON or X$$anonymous$$L.

avatar image livevlad · Mar 12, 2014 at 04:07 PM 0
Share

I understand your point and I agree. I was just thinking in an Android (with Unity of course) app. Player's preferences can be removed on the phone.

But it depends on what you want to do with your data ^^.

Thank you for your reply, it always is interesting to get other points of view.

avatar image therollingapples · Jan 31, 2016 at 10:43 PM 0
Share

Is PlayerPrefs survive when we update the game in Play Store? (As long as user don't uninstall it.)

avatar image
0

Answer by livevlad · Mar 12, 2014 at 12:45 PM

Hello,

I do not think that player's preferences are really to save scores.

You could use local files or a database. I would advise you SQLLite which is a local database (you do not need a server).

Check that : http://wiki.unity3d.com/index.php/SQLite SQLite is a very common technology, you should find a lot of tutorial even for Unity project.

Hope it helps !!!

Comment
Add comment · Show 3 · 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 Kalzong · Mar 12, 2014 at 02:03 PM 0
Share

Nice thanks :) In a matter of fact this game is for a school project. $$anonymous$$y $$anonymous$$cher have a requirements specification that it must contain a databaseconnection. So my idea was a timescore that stores in my database (that i have created in $$anonymous$$icrosoft sql management studio).

The main problem is that i like to view the highscorelist in a mvc-application.

Do you know how i can make that kind of connection to work out?

avatar image TonyLi Kalzong · Mar 12, 2014 at 02:25 PM 1
Share

When commenting on someone's answer, please click the "add new comment button under their answer ins$$anonymous$$d of posting your response as a new answer.

avatar image livevlad Kalzong · Mar 12, 2014 at 03:54 PM 0
Share

It seems to be the following architecture : Clients (Unity), server with database and Ad$$anonymous$$ part to view the list of high scores or something on browser.

I do not know if Unity have a special way to connect this kind of Database. Try to find classic tutorials about database connection in c# and software you use.

avatar image
0

Answer by BytesCrafter · Feb 02, 2017 at 06:42 PM

"United Database - Multi Platform Implementation" The first ever software of BytesCrafter. Visit our website for more info. Email us at bytescrafter@gmail.com. But if your on mobile, maybe you can use the google play game services. Yet, the bad part is that it is only available on mobile. The advantage of having your own database is that you can used it on many platforms that has an access to the internet. So, as of now we are currently making ways to minimized implementation for developers. May I invite you to our newest release of "United Database" that will be hosted on our site, dont worry its FREE. The idea is to have a unified database for your mobile and other platforms and also you can check for all the players currently registered and active. Please check the link and email us if you have any comments or suggestions: http://bytescrafter.weebly.com/database.html You know, the advantage of database is limitless. It really depends on how you used it but in general purpose. You used database for saving and loading player prefs / progress, For example, you can save your player level, experience, etc. and also, if you want to contact your player such as email ad, and another thing is when you want to see stats of your game. There are so many application for database, what you need is to think like a player. It also brings loyalty from the players as their progress can be continue, just by sharing, we are almost done with the "United Database", which in our mind, we want to deploy our games in multiplatform to have a greater chance of having more players. Supported Platform: Android, Apple IOS, Windows Phone, Smart TV, HTML5/WebGL, Windows, Apple Mac, Linux, Playstation, Xbox, Steam, Facebook Canvas, Itch.io, and many more to come including website. This software will have a flexible plan to developers, yet the software will be distributed for free with unlimited database entry but maximum database capacity of 3. #BytesCrafter #GameDevelopersOfUnity #IndieGameDeveloper #IGDA#CSharp #Php #MySQL #Database #UnityTechnologies


unitydatabase.jpg (146.0 kB)
preview.jpg (115.4 kB)
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

24 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

Related Questions

Why PlayerPrefs not working although I use "HasKey" and Save() on android? 0 Answers

how to save and retreive high score.... 4 Answers

Storing in PlayerPref based on timer 1 Answer

How do i make a script that re-fills lives after 10min? 2 Answers

Help With Quickest TimeScore 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