can’t get the WWWFom to work in b14 webplayer build.
Here is the simple script:
using UnityEngine;
using System.Collections;
public class FormTester : MonoBehaviour {
private string key0 = "abc";
private string val0 = "123";
private string key1 = "def";
private string val1 = "456";
private string msg = "";
}
void OnGUI (){
key0 = GUI.TextField(new Rect(10, 10, 200, 20), key0, 25);
key1 = GUI.TextField(new Rect(10, 50, 200, 20), key1, 25);
val0 = GUI.TextField(new Rect(220, 10, 200, 20), val0, 25);
val1 = GUI.TextField(new Rect(220, 50, 200, 20), val1, 25);
if(GUI.Button(new Rect(10,100, 100,30), "Submit")) StartCoroutine(SubmitData());
GUI.Label (new Rect(10,150,500,300), msg);
}
IEnumerator SubmitData(){
WWWForm form = new WWWForm ();
string path = "http://virtualplayground.d2.pl/WebGL/webgl_vs_unity";
if(!Application.isEditor) {
path = Application.dataPath;
}
form.AddField(key0, val0);
form.AddField(key1, val1);
WWW w = new WWW (path + "/formTester.php", form);
yield return w;
msg = w.text;
Debug.Log(w.text);
}
and the php script:
<?php
echo "I am the form bouncer: ";
foreach ($_POST as $k => $v) {
echo $k.", ".$v."; ";
}
?>
In 4.6 it works fine:
http://virtualplayground.d2.pl/WebGL/webgl_vs_unity/formtester.html
but the post array apparently doesn’t come through in webplayer in 5.0 beta ver. b14
http://virtualplayground.d2.pl/WebGL/webgl_vs_unity/formtester5.html
It does in Editor.
Also does in WebGL build.
Would that be a bug? Any suggestions welcome.