using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using System.Threading; using Cysharp.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Net; using System.Net.Http; using UnityEngine.UIElements; using System.Text; using System.Linq; using BITKit.HttpNet; namespace BITKit { public class NetworkPost : Provider, ICustomInspector { [SubclassSelector, SerializeReference] public References _url; [SubclassSelector, SerializeReference] public WebProvider webProvider; public string result; public int postCount; public int resultCount; public string content; public VisualTreeAsset customTreeAsset; public VisualTreeAsset GetCustomTreeAsset() => customTreeAsset; StringBuilder stringBuilder = new(); LimitTimes limitTimes = new(); public override async void Set(T obj) { switch (obj) { case WWWForm formFields: if (limitTimes) { try { NetworkCore.Add(_url); postCount++; result = await webProvider.PostAsync(_url, formFields); resultCount++; limitTimes.Release(); content = JsonConvert.SerializeObject(formFields); } catch (System.Exception e) { if (e is not OperationCanceledException or TimeoutException) { Debug.LogException(e, this); } limitTimes.Release(); } } break; case string _string: break; } } public VisualElement GetVisualElement() => customTreeAsset?.CloneTree(); } #if UNITY_EDITOR [UnityEditor.CustomEditor(typeof(NetworkPost))] public class NetworkPostInspector : BITInspector { } #endif }