上文中我们已经把场景中的结点全部自动完成打包,生产的有一批的资源包和结点配置文件.Xml,我们需要把资源和配置文件上传到网络上,项目制作中购买了百度网盘,上传到了网盘上,然后需要记录每一个资源以及配置文件的链接路径,可保存成txt文件,然后一起上传上去。
在资源下载前先将Xml文件和txt文件下载下来,这样就知道了每个节点位置信息,以及节点资源的链接信息,具体代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using System.Collections;
using System.Xml;
using System.IO;
class DynamicCreateNode : MonoBehaviour
{
public string xmlPath;
public string bundlesUrl;
private XmlDocument xmlDocument;
private XmlNodeList xmlNodeList;
private Queue<string> urlQueue;
private string[] urlInfo;
private bool beginLoad;
private bool IsLoad;
private int threadCount;
private string line;
private string url;
private string version;
void Start()
{
beginLoad = false;
threadCount = 0;
xmlDocument = new XmlDocument();
urlQueue = new Queue<string>();
StartCoroutine(DownLoadXml());
StartCoroutine(DownLoadText());
}
void Update()
{
if (beginLoad && threadCount < 10 && IsLoad)
{
StartCoroutine(DownLoadBundles());
threadCount++;
}
}
IEnumerator DownLoadBundles()
{
int count = urlQueue.Count;
while (urlQueue.Count