Initial commit

This commit is contained in:
MuHua-123
2024-11-01 17:14:31 +08:00
commit 5f169b90bb
216 changed files with 24712 additions and 0 deletions
@@ -0,0 +1,22 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class DataNetworkGetTexture : DataNetwork {
public Action<Texture2D> action;
public DataNetworkGetTexture(string url, Action<Texture2D> action) : base(url) => this.action = action;
public override IEnumerator IWebRequest() {
using (UnityWebRequest web = UnityWebRequestTexture.GetTexture(url)) {
yield return web.SendWebRequest();
RequestResultHandle(web);
}
}
public override void RequestResultHandle(UnityWebRequest web) {
base.RequestResultHandle(web);
bool isDone = !web.isDone || web.result != UnityWebRequest.Result.Success;
if (isDone) { action?.Invoke((web.downloadHandler as DownloadHandlerTexture).texture); }
}
}