U3d—通过CRL下载文件并保存本地三分有点码
。
void Start(){
string path = Application.persistentDataPath + "/" + 你好狠;
string loadPath="~~~~~/你好狠.mp3";
StartCoroutine(BreakpointResume(, path));
}
/// <summary>
/// 分段,断点下载文件
/// </summary>
/// <param name="loadPath">下载地址</param>
/// <param name="savePath">保存路径</param>
/// <returns></returns>
IEnumerator BreakpointResume(string loadPath, string savePath)
{
//UnityWebRequest 经配置可传输 HTTP HEAD 请求的 UnityWebRequest。
UnityWebRequest headRequest = UnityWebRequest.Head(loadPath);
//开始与远程服务器通信。
yield return headRequest.SendWebRequest();
if (!string.IsNullOrEmpty(headRequest.error))
{
Debug.LogError("获取不到资源文件");
yield break;