Hi everyone this is doing my head in, I am new to unity3d (a week or so) and the more I get into it not only the more I love but the harder and harder. ;-)
Anyway I have server side php files that save to txt to display the total visitors as well as the current number visiting, how can I show this within a GUI environment like a HUD.
I have tried loads of different ways and I just can't get my head around it.
Luckily the Unity team have made this really simple:
var dataString: String;
var url = "http://www.mysite.com/data.txt";
function Start () {
// Start a download of the given URL
var www : WWW = new WWW(url);
// Wait for download to complete
yield www;
// assign data from URL to string
dataString = www.data;
}
function OnGUI() {
GUI.Label(Rect(100, 100, 140, 20), dataString);
}
you can use WWW class to download any resource from the web. you can just get the data and parse/show it yourself or tell unity that it's an audio file and tell it to play the audio. also you can tell it's a video or a package of assets that unity can use in a game. this is one of the powerful features of unity. the code example of MotionReactor is good and complete. also you can use the WWWForm class to send form data to a form in a webpage and submit the form. you can even data fields like images or movies or ...