You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System.Text;
- using UnityEngine;
- using UnityEngine.Networking;
-
- public class WWWRequest
- {
- public string ToJson()
- {
- return JsonUtility.ToJson(this);
- }
-
- public string ToQueryString()
- {
- var properties = GetType().GetFields(); // 获取所有字段
- var queryString = new StringBuilder();
- foreach (var prop in properties)
- {
- // 将字段名和值转换为查询字符串格式
- string key = UnityWebRequest.EscapeURL(prop.Name);
- string value = UnityWebRequest.EscapeURL(prop.GetValue(this)?.ToString() ?? string.Empty);
- queryString.Append($"{key}={value}&");
- }
-
- // 去掉最后一个 '&'
- if (queryString.Length > 0)
- {
- queryString.Length--;
- }
-
- return queryString.ToString();
- }
- }
-
- public class WWWResponse
- {
-
- }
|