- Home /
Problem is not reproducible or outdated
Unity3D WWW takes URL from address bar
I am using the WWW class and using it to get score from getScore.php.. It works but when i built it and run on the web player it won't work.
I checked using"Inspect Element" and actually it called http://company.com/game/company.com/game/getScore.php when I need it to call http://company.com/game/getScore.php
The address from the address bar is added in front of the url that I wanted to call.Does anybody know the reason for this to happen? This is the code I'm using.
using UnityEngine;
using System.Collections;
public class score : MonoBehaviour {
public GUIText scoreText;
string theURLis = "http://company.com/game/getScore.php";
// Use this for initialization
void Start () {
StartCoroutine ("getScore");
}
void OnGUI () {
if (GUI.Button (new Rect (600, 400, 50, 30), "back"))
back ();
}
void back() {
Application.LoadLevel ("menu");
}
IEnumerator getScore() {
WWW getScoreText = new WWW (theURLis);
yield return getScoreText;
scoreText.text = getScoreText.text;
}
}
Answer by Bunny83 · Dec 18, 2013 at 07:26 PM
Since your code contains a dummy address, are you sure your URL starts with "http://"? Also are you sure you don't do any strange changes at runtime? Try printing the URL right before the WWW call and check the logfile
wtf, suddenly it works.. i don't know what was the problem. hmmm.. thanks for replying
Follow this Question
Related Questions
Is it possible to load a script from a url? 1 Answer
Load texture on disabled GameObject 1 Answer
Video 'not supported' on iPad 1 Answer