# How do I make a highscore database for Unity?

I have been looking around, but I haven't found the perfect answer, yet.

I want to to send scores from Unity to a database, without a username, and display the high scores in the highscore menu. How do I do that?

There are plenty of pitfalls in designing a system like this. If you are opening up a path to post high scores to a server, you are opening it for everyone - not just your client application. The general rule of thumb is this kind of territory is to never trust what the client is telling you. As soon as you hand the application to someone you've basically given them the key to posting whatever they like.

For a start, you're going to need some way of accepting requests from over the internet - you're best bet is probably using HTTPS. You should also have a database that this interface can connect to (never directly expose your database to the open network, always write a middle-ware application to interface with the outside world and your database). You'd probably be best off with something like a PHP server, or a NodeJS server, or really any back-end technology that is relatively simple and can both connect to a database and accept HTTP requests; personally I'd choose NodeJS but that's because I like it and think it would serve this purpose well.

Next you'd probably want to start implementing a RESTful service on it, you'd need the ability to retrieve high scores, the ability to add them and possibly the ability to update them if you feel it is necessary. You'd simply make a POST request to your web-facing server, and your server's middle-ware would interpret the data and do what is necessary (either fetching the requested high scores, or inserting a new one in this case).

You could roll-your-own in this case and forgo using the ideas behind REST, but I'd suggest following some form of best practice.

Actually the answer is not short or concist of single line. You required Details guide line/tutorial for that and you can achieve it in two ways

You either require your own server with your code logic(back-end) or you can use free firebase as a backend.

1. Details guide given by unity wiki Server Side Highscores
2. Or you can check Firebase with unity

I'd do this by:

1. Get a server running with the ability to host on the open net (virtual or otherwise - virtual would probably be easier/cheaper at this stage.)
2. Install a LAMP (Linux, Apache, MySQL, and PHP/Python/Perl) stack on it
3. Build a small HTTP interface that updates, or inserts, into the database a name & score
4. Build a small HTTP interface that returns the high score table

Display in game, using the UI & control with http requests.

That gets you up and running.

Better way, but more effort, is to integrate with Steam and to use their high score table (Leaderboard) API

• Alot of assumptions are made in this answer (such as it runs on PC and OP is happy integrating with steam). Also, a simple HTTP interface would end up with a few thousand users with ludicrous "high scores" that have been manually inserted outside of the OPs application. – Trotski94 Oct 13 '16 at 9:19
• Yes that's why it gets you up & running but is not really a shippable solution. Shippable really requires integrating with a production Leaderboard system, like Steam's. You are correct I had presumed that poster was on PC but if they are working on PS4 / Xbox one then they'd need to integrate with PSN / Live! instead. – PompeyPaul Oct 13 '16 at 11:59