1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using TMPro;
- using UnityEngine;
- using UnityEngine.Networking;
- using UnityEngine.UI;
- namespace Assets
- {
- public class DlgLoading : MonoBehaviour
- {
- public TMP_InputField inputField;
- public Button confirmBtn;
- string url = "";
- private void Awake()
- {
- confirmBtn.onClick.AddListener(() =>
- {
- StartCoroutine("SendRequest");
- });
- }
- IEnumerator SendRequest()
- {
- UnityWebRequest request = UnityWebRequest.Post(url,inputField.text);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.Success)
- {
- Debug.Log("发送完成");
- if (request.downloadHandler.text =="true")
- {
- }
- else
- {
- }
- }
- else
- {
- Debug.Log("发送失败");
- }
- StopAllCoroutines();
- }
- }
- }
|