Database Control Pro Documentation
Version 1.0.0 onwards



Contents > The Demos > The Login Demo
The Login Demo

The Login Demo is one of the best places to start when using Database Control Pro. It shows a simple Login/Register system where the player can save an load a data string which is saved in the database.
If you want to use a more complex setup with Database Control Pro which is still based on user accounts then we would suggest starting with the Login Demo and building on it.

Make sure you have setup the demo before you try using it.
Once you have setup the demo, you can delete the 'DeleteMe' object from the scene. (It is a child of the canvas)

The Login Demo can be found at:
Assets>Database Control Pro>Demos>Main Demos>Login Demo>DCP Login Demo

The login demo uses the Smooth UI animation system to fade the UI elements in and out.

All of the code is in a single script called 'LoginDemo_Accounts' which is attached to the 'AccountsManager' GameObject.


The Structure of the Database:

First play the demo and register at least one account. Then Open the Setup Window and View the Database which you set the demo up with.

The Database should look something like this:

The first column of the database stores the player's usernames.
The second column of the database stores the player's passwords.
The third column of the database stores the player's data string.

This means every row of the database represents a single player's account.


The Command Sequences:

The Login Demo comes with 4 Command Sequences:

1. Login: This sequence looks down the first column of the database (through all of the usernames), and looks for the submitted player username. If it isn't found, 'UserError' is returned. If it is found the 2nd column of the player's row is looked at (the player password), if this is the same as the submitted password 'Success' is returned, otherwise 'PassError' is returned. This sequence is run when the 'Login' button is pressed.

2. Register: This sequence looks down the first column of usernames and makes sure none of the usernames are the same as the submitted username. If they are then 'username in use' is returned as the player has to choose a different username. If it is not in use then 'Success' is returned after adding a new row to the database containing the submitted username and passsword with 'Hello World!' as the data string. The sequence is run when the player presses 'Register' to show the register UI and 'Register' again to register a new account.

3. Get Data: This sequence is very similar to the 'Login' sequence. The sequence looks down the first column of the database for the player's username. If it is found then it checks the submitted password with the value from the second column of the same row. If the password is correct then the sequence returns the data string which is retrieved from the third column of the row. If the username is not found or the password is not correct, 'Error' is returned. The sequence is run when the player has logged in and the 'Get Data' button is pressed.

4. Set Data: This sequence is also very similar to the 'Login' sequence. The sequence looks down the first column of the database for the player's username. If it is found then it checks the submitted password with the value from the second column of the same row. If the password is correct then the sequence returns 'Success' after setting the value in the third column of the row to the submitted data string. If the username is not found or the password is not correct, 'Error' is returned. The sequence is run when the player has logged in and the 'Set Data' button is pressed.