Setting up a leaderboard using PHP/MySQL
Games are more fun when there is a leaderboard of high scores that the players have achieved. Even single player games can communicate to a shared web-based leaderboard. This recipe includes both, the client side (Unity) code, as well as the web-server side (PHP) scripts to set and get the player scores from a MySQL database.
Getting ready
This recipe assumes that you either have your own web hosting, or are running a local web server and a database server, such as XAMPP or MAMP. Your web server needs to support PHP, and you also need to be able to create the MySQL databases.
All the SQL, PHP, and C# scripts for this recipe can be found in the 1362_10_07
folder.
Since the scene contains several UI elements and the code of the recipe is the communication with the PHP scripts and SQL database, in 1362_10_07
folder, we have provided a Unity
package called PHPMySQLeaderboard
, containing a scene with everything set up for the Unity project.
Note
If you are...