Hi guys, If I send a variable from php to c# in unity, it works. But if I need this variable in another function , it doesn’t work and I receive “0”.
I tryed to insert the string that c# receive from php page into another variable that I have declared into class, but it not work yet. How could resolve the problem?
this is my code in c#
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public GUIText highScoreText;
public string rec;
public float recf;
void Awake()
{ string wwwResponse = "http://localhost/Game/user.php";
WWW www2 = new WWW(wwwResponse);
StartCoroutine(send(www2));
}
void Start()
{ Debug.Log(recf);
highScoreText.text = "Local Highscore: " + recf ;
}
IEnumerator send(WWW www2)
{
yield return www2;
print(www2.text);
rec=www2.text;
recf=float.Parse(rec);
Debug.Log(recf);
}
In print(www2.text) and Debug.Log into function IEnumerator send, I receive the information (13) instead in the function Start I receive 0