Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

Can't get the WWWFom to work in 5.0 b14 webplayer build.

Discussion in 'Unity 5 Pre-order Beta' started by tomekkie2, Dec 16, 2014.

  1. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    can't get the WWWFom to work in b14 webplayer build.

    Here is the simple script:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class FormTester : MonoBehaviour {
    5.     private string key0 = "abc";
    6.     private string val0 = "123";
    7.     private string key1 = "def";
    8.     private string val1 = "456";
    9.  
    10.     private string msg = "";
    11.  
    12.  
    13.     }
    14.    
    15.     void OnGUI (){
    16.         key0 = GUI.TextField(new Rect(10, 10, 200, 20), key0, 25);
    17.         key1 = GUI.TextField(new Rect(10, 50, 200, 20), key1, 25);
    18.         val0 = GUI.TextField(new Rect(220, 10, 200, 20), val0, 25);
    19.         val1 = GUI.TextField(new Rect(220, 50, 200, 20), val1, 25);
    20.  
    21.         if(GUI.Button(new Rect(10,100, 100,30), "Submit")) StartCoroutine(SubmitData());
    22.  
    23.         GUI.Label (new Rect(10,150,500,300), msg);
    24.     }
    25.  
    26.     IEnumerator SubmitData(){
    27.         WWWForm form = new WWWForm ();
    28.         string path = "http://virtualplayground.d2.pl/WebGL/webgl_vs_unity";
    29.         if(!Application.isEditor) {
    30.             path = Application.dataPath;
    31.         }
    32.  
    33.         form.AddField(key0, val0);
    34.         form.AddField(key1, val1);
    35.  
    36.         WWW w = new WWW (path + "/formTester.php", form);
    37.  
    38.         yield return w;
    39.  
    40.         msg = w.text;
    41.         Debug.Log(w.text);
    42.     }

    and the php script:
    Code (CSharp):
    1. <?php
    2.  
    3. echo "I am the form bouncer:  ";
    4.  
    5. foreach ($_POST as $k => $v) {
    6.     echo $k.", ".$v.";   ";
    7. }
    8. ?>
    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.
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Sounds like it. Please report it.
     
  3. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    I did.
    Can anyone tell me if whether this woulld work in 5.0 b17?:)
     
  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    946
    It works the same in b17 (the forms do not work in webplayer build)

    I can not also get SystemInfo.deviceUniqueIdentifier to work in WebGL build.

    I need both features to use in the web apps.

    Forms could be sent to the webpage and resent from there, but should work from the webplayer build.