c# - Unity3d WWWForm only works from Start() -


I have the following code that works fine and sends the data as needed:

  IEnumerator start () {Diffculty d = Diffculty.getInstance (); Int level = d.getDiffculty (); WWWForm form = new WWWForm (); Form.AddField ("Highest Score", 1000); Form.AddField ("name", stringToEdit); Form.AddField ("Level", Level); WWW download = new WWW (URL, form); Yield returns download; If ((string.easynearction (download.air)) {debug. Log ("Error downloading:" + download.error); } Else {Debug.Log (download.text); DoWindow0 = false; }}  

However, now I want to trigger this code on a button press in a gyindo so that the code below is below.

  IEnumerator senddata () {Diffculty d = Diffculty.getInstance (); Int level = d.getDiffculty (); WWWForm form = new WWWForm (); Form.AddField ("Highest Score", 1000); Form.AddField ("name", stringToEdit); Form.AddField ("Level", Level); WWW download = new WWW (URL, form); Yield returns download; If ((string.easynearction (download.air)) {debug. Log ("Error downloading:" + download.error); } Else {Debug.Log (download.text); DoWindow0 = false; }} Zero DoWindow0 (int windowID) {stringToEdit = GUILayout.TextField (stringToEdit, 25); If (GUILayout.Button ("Submit Score")) {senddata (); }} Zero OnGUI () {// doWindow0 = GUI.Toggle (new rack (10, 10, 100, 20), doWindow0, "Window 0"); If (doWindow0) GUI.Window (0, windowRect, DoWindow0, ""); }  

However, when I press the button ("submit score") nothing happens and the data is not received by the server

< Div class = "post-text" itemprop = "text">

That's because you are not calling StartCoroutine (sendData ()). To send the calling data, as soon as you have returned the required Inimeterar value to the loop through the method, where the startcorinine actually uses IEnumerator to complete the method.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -