Hey guys…
I was following this example here:
and there are 3 little things that are not very clear to me, and maybe you can help me out:
-
the script should be placed within the Scene from Start up >>> meaning in the first scene, or where the users will type in their names?
-
to send the data to the db, it should be something like if (GUI.Button(new Rect(50,50,50,50)“ENTER”){ SaveScores();}???
-
If I keep a “local db”, with xampp; will it work the same way, but the data will be stored in my computer?
Thanks a lot to all of you!
ya ,ur data will be in ur machine
public string db_url = "http://localhost/unity_test/";
private GUIText myDb;
void Start()
{
myDb = GetComponent<GUIText>();
}
void OnGUI()
{
if (GUI.Button(new Rect(Screen.width * .8f, Screen.height * .22f, Screen.width * .2f, Screen.height * .1f), "HIGH SCORES"))
{
highScores = true;
}
if (highScores)
{
StartCoroutine(LoadScores());
}
}
IEnumerator LoadScores()
{
WWW webRequest = new WWW(db_url + "LoadScore.php");
yield return webRequest;
myDb.text = webRequest.text;
}
So, by doing this, the user will get the HS stored, “printed” in a GUIText, right?
(of course, there is a GUIText component attached to the main camera)