There is a JS script output of my SQL databases to GUI.Label and it works great!
But as you know, this method does not support dynamic fonts, and correspondingly different screens on the Android devices ..
I'm trying to display text in UILabel.tex from JS:
public var scriptEnabled:boolean = false; //Set to true when you want the score submitted.
//public var windowRect : Rect = Rect (20, 20, 20, 20);
//public var useSizeAsPadding:boolean = true;
public var phpScriptFolder:String = "http://example.com/leaderboard/";
public var cellWidth:int = 100;
public var sortBy:String = "var0";
public var start:int = 0;
public var count:int = 100;
public var condition:String[]; //This is for selecting levels, usernames, etc. IE, using my default 4 variables,
// to check for a level named demo you would type in var3 = "Demo"
public var exclusionList:String[] = ["id"];
public var direction:String = "DESC"; //DESC for descending ASC for ascending
public var refresh:boolean = false;
//public var guiID:int = 1;
public var labelScore:GameObject;
private var i:int = 0;
var scores
:Array
= new Array
(""); private var gettingScores:boolean = false;
function Start()
{
for(i = 0; i<= count; i++)
{
scores.Push("");
}
i=0;
}
function Update()
{
if(refresh)
{
GetScores();
refresh = false;
}
}
function GetScores()
{
gettingScores = true;
var tmpExclude:String;
for(var field in exclusionList)
{
if(field != "")
{
tmpExclude += field + "~";
}
}
var conditions:String = "&conditions=";
for(i = 0; i < condition.Length; i++)
{
conditions += condition[i].Replace("=", "----").Replace(" ", "%20") + "~"; //Replace fixes not having the extra = in a url, which breaks the url.
}
var res
:WWW
= new WWW
(phpScriptFolder
+ "/getScores.php?sort=" + sortBy
+ "&direction="+ direction
+ "&start=" + start
+ "&limit=" + count
+ "&exclude=" + tmpExclude
+ conditions
); print(phpScriptFolder + "/getScores.php?sort=" + sortBy + "&direction="+ direction + "&start=" + start + "&limit=" + count + "&exclude=" + tmpExclude + conditions);
yield res;
print(res.text);
var resTmp = res.text;
var tmp:Array = resTmp.Split("\\"[0]);
scores = tmp;
gettingScores = false;
//NGUIScorePrint ();
}
function OnGUI ()
//function NGUIScorePrint ()
{
if(scriptEnabled)
{
if(scores[0] == "")
{
if(gettingScores == false)
{
GetScores();
}
}
else
{
Leaderboard();
}
if(scores[0] != "")
{
//Resets scores so that it looks for new information when displayed again.
for(i =0; i<= count; i++)
{
scores.Push("");
}
}
}
}
function Leaderboard ()
{
for(i = 0; i <= scores.Count-1; i++)
{
var tmp:Array = scores[i].ToString().Split("\\"[0]);
var j:int = 0;
for(j = 0; j <= tmp.Count-1; j++)
{
//labelScore.GetComponent(UILabel).text = tmp[j].ToString();
labelScore.GetComponent(UILabel).text = scores.ToString();
}
}
}
But getting the output:
hendry;87400,aLDime=);74400,taz;37900,F;37700,nat1;36400,miki ser;34400,hendry;29900,toad;29300,shaggy;21600,florent;20900,nat1;17300,msr;17000,hendry;12800,CM;10100,tttttt;9400,f2241;9100,ziol;8400,taz;7900,哦;3300,No spaces and newline!
As I see, C# does not understand this line:
var tmp:Array = scores[i].ToString().Split(";"[0]);
I know it's a matter of language JS and C #, and the answer is somewhere nearby, but I'm at an impasse and beg for help! If you can not make the "Array" from JS to C #, may be then tell how to do that would UILabel . text did sign with the appearance of a space "
;" and the transfer line with "
,"
Excuse me, I'm newbie))
Before very grateful!!!