Hello. If I used this CODE is all ok. materials_list[material_id] have value.
#pragma strict
private var www_page : String[];
private var materials_list : String[];
var material_id : int;
function Start () {
var BaseURL = "path to .php file on website";
var form = new WWWForm();
form.AddField("UserID", PlayerPrefs.GetString("UserID"));
form.AddField("Location_Type", 0);
form.AddField("Planet_Id", PlayerPrefs.GetString("Planet_01_id"));
var w = WWW(BaseURL, form);
yield w;
www_page = w.text.Split("<"[0]);
materials_list = www_page[0].Split(","[0]);
guiText.text = materials_list[material_id];
}
But if I use this code then materials_list[material_id] is empty! In LOG i have error (Index out of bound)
#pragma strict
private var www_page : String[];
private var materials_list : String[];
var material_id : int;
function Start () {
GetVariables();
guiText.text = materials_list[material_id];
}
function GetVariables(){
var BaseURL = "path to .php file on website";
var form = new WWWForm();
form.AddField("UserID", PlayerPrefs.GetString("UserID"));
form.AddField("Location_Type", 0);
form.AddField("Planet_Id", PlayerPrefs.GetString("Planet_01_id"));
var w = WWW(BaseURL, form);
yield w;
www_page = w.text.Split("<"[0]);
materials_list = www_page[0].Split(","[0]);
}
What is wrong in this script?
PHP file returns the correct value
1,2,3,4,5,6,7,8,9,10
I am using the SPLIT <because the site gives me the advertising and I have to remove.
But in the first script is the same, and if the procedures for communication with PHP file does not throw the outwardly function is well.
Why is filled with an array inside a function outside is suddenly empty, even though I declare it at the beginning of the file?
Sorry for my english.