- Home /
How can i make some kinda Login System?
Hi peepz!
I'm wondering if you guys/girls could help me with my problem!
I need some kind of Login System thingy i know how to make the Password field and the Text field but this is my problem i dont know how to save the login details so you can exit the game without registering again and start all over!
If you can help me with this problem i would be so happy!
Thx in advance!
Answer by duck · Apr 15, 2010 at 01:19 PM
Typically, log-in systems are implemented using server-side scripting languages, such as PHP, Perl or ASP.
In this way, your unity player would act as a 'client', and would send the username & password which the user typed to the server. The server then looks this up in the users database, and gives the appropriate response.
If you are not using a server/client model however, you'll need to provide more information about how you are planning to have your registration system to work. Should it be that all user's information is stored on one machine? (this means if a user goes to play on another machine, their login & saved data will not be present).
See this answer:
How can I send a string or integer value to server side scripts or web services?
And google for login systems in your chosen server-side language:
Simple Log In System in PHP
Simple Log In System in ASP
Simple Log In System in Perl
These should get you on your way!
Answer by Cyclops · Apr 15, 2010 at 02:01 PM
What Duck said. :) But to add some detail, you might want to read How Unity Communicates with the Browser. In particular, there are two functions:
SendMessage allows HTML Javascript to call a Unity object's function.
Application.ExternalCall lets Unity call HTML Javascript function.
By HTML Javascript, I mean the Javascript in the web-page's HTML - as opposed to Unity's own Javascript :)
So with these functions, you have two-way communication between your web-page HTML, and your Unity game. The HTML can handle any kind of authentication you need, and pass the results to the game.
As Duck says, you still have to implement the login checking somewhere, but at least these functions make it easier to pass the results to Unity.
Update: take a look at: Unity Browser Cookie Equivalent, it may be what you're looking for. It's a way of saving player preferences.
I'm surprised Duck hasn't already linked it. :)
I think for a server-side log-in system you wouldn't necessarily want to communicate with browser-based javascript functions. $$anonymous$$ore commonly you'd communicate directly with the server using Unity's WWW class.
i meant just make an file that contains the username and password and you register in game and you username and password are saved in a .txt file or something!
If you're using the Web-browser version of a Unity game, then you can not write files on the player's PC, for security reasons. So you still have to communicate the login information to the server side. See @Duck's first link for how to do that.
Im not going to make a website version its just download and play