I have been working on a way to let “players” create an account with a username and password. Then they can save their progress to that account and it loads up again when they sign in later.
I’m doing this for the Unity WebPlayer format, not the standalones. When I finish this (and I think I’m getting close), I will share the method for anybody to use.
My plan is to create a javascript in the Unity game that calls a .php script on the webserver. The .php script would then collect certain variables from Unity (such as username/score/etc). Then it would serialize the variables (save them in a text file on the webserver).
My question is directed to PHP users. How does the serialize function work? I am not familiar with PHP. I have found multiple articles on the web, but they don’t use very good examples. I just can’t quite understand. So if any of the Awesome Unity People could help me out on this, it would be much appreciated.
That’s purely up to you how you store them on the server. You can use a database, or a data file on the hard drive, or whatever. My first foray years and years ago into that I was writing text files to store that information. You don’t need to serialize the data if it’s just username and password.
you can use the www clas to send your variables to the php by adding ‘?myvar1=myvartosave’ and in php you can catch those by using the GET method : myvarreceived = _GET[‘myvar1’];
are you sharing your project or? I want to make a same thing as you for my game wher eyou first have to login with username and password but i don’t know how to save the data in sql database never worked with it before… can you guys give me a small tut or point me in the right direction?
I want to make the accounts with a php script in a webpage but you have to login with that account in a unity game. so where to start for something like that?
Search on Google for PHP mysql, there are plenty of good tutorials on it. Once you have the php connected to the database and a user in it, you can start on the Unity part. You can use the WWW class to post and retrieve data from PHP. PHP will handle the connection to the database.