Hello!
I’ve been working on a external play test tool and have almost everything working, except sending floats to my database with the WWW function in Unity3D.
The problem is as following. This is the URL I managed to create:
http://somepage?playerName=Test2&playerIP=123.45.324.25&level=3&time=346,476
Notice the comma (,) at the last variable? URL’s dont get that. I need that comma to change into a point!
Anyone, please? (cookies?)
1 Like
Even this does not work:
time.ToString("#,##0.00");
1 Like
What’s the code you use to build that script?
Either it’s taking into account your local culture settings, or it’s something else in that script.
Regardless, you can have this as a bandaid workaround:
time.ToString().Replace(“,”, “.”);
EDIT: The other option is to URL-Encode your entire URL:
url.Replace(“,”, “%2C”);
function Start () {
var test : String = "Test, to see...";
print (test);
test = test.Replace (",", ".");
print (test);
}
Edit : doubled-crossed while testing.
1 Like
First of all, your workaround works and you are awesome. Cookies at the bottom of this page.
The code to build my script? I have no clue, Unity3D does that for me and it’s all like magic to me
The part that builds the URL is as following:
string url = postURL +
"playerName=" + WWW.EscapeURL(playerName) +
"&playerIP=" + playerIP +
"&level=" + level +
"&time=" + time.ToString().Replace(",", ".");;
WWW post = new WWW(url);
And the float time is just a regular float…

In order for floats to always use decimals, put this in a Start or Awake function:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
–Eric
3 Likes
Good call, Eric.
YES COOKIES
Meanwhile I thought you may have been referring to browser cookies (the web-developer in me I suppose).
Note that you have two semi-colons at the end of that URL; won’t break anything though.
The browser would still make a comma of it, so that aint the solution 
This…
url.Replace(",", ".");
…does the job
Thanks again!
1 Like
Oh, I thought your issue was about the browser not accepting the comma in the URL, not that the server-side code doesn’t handle the comma properly. 
A PHP GET function can’t handle comma’s apparently. Sorry for the misunderstanding.
And damn guys, I’ve never had so many responsed in just a minute or 2. <3
PHP GET won’t handle commas even if you URL-Encode them? I have to see that to believe it!
This is where the browser comes in; I’m using Chrome, which does all the URL decoding automatically - changing all encoded characters back to something the audience can read. So it makes a comma out of %2C. And obviously, I want all browsers to work ^^
That being said, there must be a difference between submitting encoded urls to any browser and chrome.