Database Control Pro Documentation
Version 1.0.0 onwards

Contents > The Demos > The Chat Demo
The Chat Demo

The Chat Demo is different to the other demos as it is not based on user accounts. Instead the Chat Demo provides an example of an online chat which anyone can use with any username.
The Chat Demo allows a player to see the online chat which is taking place and post their own comments. The chat is saved to the database so even if the player closed the game and reopened it, they could carry on from where they left and would still be able to see all their previous comments.
This demo could be combined with a muliplayer networking chat (e.g. Photon's Chat) to create a more responsive chat system which remembers all posts.

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 Chat Demo can be found at:
Assets>Database Control Pro>Demos>Main Demos>Chat Demo>DCP Chat Demo

The Chat Demo uses the Smooth UI animation system to fade the UI elements in and out. It also makes use of some Unity UI elements for automatic UI layouts.

The UI is split up into the Chat UI, the Choose Name UI, and the loading UI (shown when transitioning between the other two). Nearly all the code is in the DCP_CD_MainControl script attached to the 'MainControl' GameObject.

The Structure of the Database:

First play the demo and post a few comments preferably with different usernames. 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 usernames used to make each comment.
The second column of the database stores the text which makes up each comment.

This means every row of the database represents a comment. The comments at the top were the first to be posted and the comments at the bottom were posted more recently.

The Command Sequences:

The Chat Demo comes with 2 Command Sequences.

1. Get Chat Data: This sequence gets all of the data from the first and second columns and returns it to the game to show to the player. This sequence is run when the player has submitted a username to join the chat and when the chat is refreshing.

2. Post Comment: This sequence adds a new comment to the database. It adds the submitted username and submitted comment text to the first and second columns of the next row in the datsbase. It is run when the player submits a new comment in the chat.