Hello,I want to display my player stats from my database to my unity game.The thing is when i run the game in the editor everything is fine but when i’m playing it on my android phone the stats are not there.Here is my script
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class displayDataFromPhp : MonoBehaviour
{
public static displayDataFromPhp _INstance;
public Text namee;
public Text lvl;
public Text atc;
public Text def;
public Text cash;
public Text hp;
private GameObject _Manager;
public string warriorname;
public string dbUser;
public string dbMoney;
string answer;
public string[] stats;
string url = "http://ptixiaki.sotirisoikonomou.com/CodeIgniterUnity/index.php/Users/guser";
public void Start()
{
if (_INstance == null)
{
_INstance = this;
DontDestroyOnLoad(this.gameObject);
_Manager = GameObject.Find("playerStats");
}
else if (_INstance != this)
{
Destroy(gameObject);
}
WWWForm www = new WWWForm();
www.AddField("user", internetCalls._Instance.LoggedInUsername);// stelno sto arxeio tis php(contoller users)stin function guser to global username pou exo parei gia na dei an uparxei stin vasi
WWW get_www = new WWW(url, www);
StartCoroutine(WaitForRequest(get_www));
}
//Our Coroutine for getting the data
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// check for errors
if (www.error == null)
{
//Assign the data that was fetched to the variable answer
answer = www.text.ToString();
stats = answer.Split(","[0]);
warriorname = stats[0];//to name
dbUser = stats[6]; // to username
dbMoney = stats[4]; // ta lefta
}
else {
Debug.Log("WWW Error: " + www.error);
}
}
//GUI Components
void OnGUI()
{
namee.text = stats[0]; //emfanizei apo tin vasi mou ta stoixeia
lvl.text = stats[1];
atc.text = stats[2];
def.text = stats[3];
cash.text = stats[4];
hp.text = stats[5];
}
}