Unity微端场景加载(二)场景资源的下载和显示

本文继续探讨Unity微端场景加载的实现,主要介绍如何将打包后的场景资源和配置文件上传至网络(如百度网盘),并记录资源链接。通过下载XML配置文件和资源链接TXT文件,获取节点位置及资源链接信息,实现资源的下载和在微端中显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

上文中我们已经把场景中的结点全部自动完成打包,生产的有一批的资源包和结点配置文件.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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值