RequestData.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using UnityEngine;
  2. using UnityEngine.Networking;
  3. using System.Collections;
  4. using UnityEngine.UI;
  5. using Unity.VisualScripting;
  6. using System;
  7. using UnityEngine.SceneManagement;
  8. public class RequestData : MonoBehaviour
  9. {
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. string LoginUrl = EnviromentSetting.serverIp + "/api/login/";
  14. //StartCoroutine(RequestData(LoginUserName.text, Loginpassword.text, LoginUrl));
  15. }
  16. // Update is called once per frame
  17. //private IEnumerator RequestData(string mobileNumber, string password, string url)
  18. //{
  19. // // Create a form and add parameters to the POST request
  20. // WWWForm form = new WWWForm();
  21. // form.AddField("mobile_number", mobileNumber);
  22. // form.AddField("password", password);
  23. // // Assign the form to the request
  24. // UnityWebRequest request = UnityWebRequest.Post(url, form);
  25. // // Send the request and wait for a response
  26. // yield return request.SendWebRequest();
  27. // //Debug.Log("接收信息request: " + request.result);
  28. // // Check for errors in the request
  29. // if (request.result == UnityWebRequest.Result.Success)
  30. // {
  31. // // Output the error if there's a problem
  32. // Debug.Log("接收信息Response: " + request.downloadHandler.text);
  33. // //SceneManager.LoadScene("Loading");
  34. // }
  35. // else
  36. // {
  37. // // Output the response data if the request was successful
  38. // Debug.LogError("接收信息Response: " + request.downloadHandler.text);
  39. // }
  40. //}
  41. }