Hi community
i want to use Amazon SimpleDb or DynamoDb for storing data (like scores for example), but i don’t know how to connect at the database from Unity. Anyone used this? Are there any resources or tutorials on using Amazon and Unity?
Hi community
i want to use Amazon SimpleDb or DynamoDb for storing data (like scores for example), but i don’t know how to connect at the database from Unity. Anyone used this? Are there any resources or tutorials on using Amazon and Unity?
Nobody?
Any idea of another storing service which can be used with unity?
Use WWW to talk to your server which runs the database.
Thank you Graham,
I will give it a try
Any luck?
No, instead of using SimpleDb i’ve followed the Graham Dunnett’s advice and i’ve used a Amazon EC2 virtual server running a linux instance where i’ve created a database, and using www class from Unity i was able to connect to that database (also i’ve used some php code to manipulate data)
Hmm… I’ve set up an ec2 instance before but haven’t connected to it, just an s3 so far. So basically it makes it’s own database and you access it that way right? Do you mind sharing some more insight (in the midst of my first app )? I’m still learning AWS. Was it a preconfigured API?
Hi Nezz, check this links:
this one is how to set up PHP and MySql on Amazon EC2
http://www.alexkorn.com/blog/2011/03/getting-php-mysql-running-amazon-ec2/
and this one is how to connect to a Linux instance to be able to make changes on it
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html
And here is a small piece of PHP code for adding data into “players” table (this is stored on Amazon instace):
<?php $mysqli = new mysqli('localhost', 'UserName', 'Password', 'Players'); if( mysqli_connect_errno() ) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $id = $_POST['id']; $name = $_POST['name']; $score = $_POST['score']; $query = "INSERT INTO players VALUES ($id, '$name', $score)"; $mysqli->query($query); printf( $mysqli->affected_rows ); $mysqli->close(); ?>Here is a piece of code from Unity, using WWW class to call “insertplayer.php” and add data into the “players” table
IEnumerator InsertPlayer()
{
WWWForm form = new WWWForm ();
int.TryParse (_id, out id);
int.TryParse (_score, out score);
form.AddField (“id”, id);
form.AddField (“name”, pName);
form.AddField (“score”, score);
WWW w = new WWW(“http://ec2-[IP ADDRESS].compute.amazonaws.com/insertplayer.php”, form);
yield return w;
print (w.text);
}
I’m setting the values for _id and _score in textfields from OnGUI
Hope that this helps you, tell me if there are any problems