hello friends i need help.
i have a php file with one variable:
$test= “this is a text”;
i need pass from php to unity this variable can you helpme please?
i read something about WWW, but i dont understand how to unity reciebe this variable.
The idea is that I have a database in php, I create a 3D gallery where each field should be stored in mysql and open the gallery data, such as name age and sex are loaded from the database. … can someone help?
in the php file contains a variable how to send to unity
sorry for my english…:shock:
You use WWW to receive the data and “read” it using WWW .text
var url = "http://www.somesite.com/somescript.php";
function Start () {
var www : WWW = new WWW (url);
// Wait for download to complete
yield www;
var text = www.text;
Debug.Log(text);
}
Your PHP would contain:
$test= "this is a text";
echo $test;
Now of course you might want to pass more than one string. For that you will have to serialize the data in PHP in a format like XML or JSON, “echo” it, and then unserialize it once you get it back in Unity. JSON is more lightweight than XML, but with XML you have the advantage of using the built in serialization/deserialization in .NET.
There are other threads that deal with these issues (serialization). What you first need to do is get the text into Unity using WWW.