コード例 #1
0
    //--------------------------------------------------------------------------------------------
    // 保存资源列表, 存在则合并
    public static void WriteResList(Dictionary <string, ResPackItm> tbl, BuildTarget tgt)
    {
        Dictionary <string, ResPackItm> ntbl = tbl;
        string sPth = BuildGameCMD.GetBuildFolder(tgt);

        sPth = sPth.Replace("\\", "/");
        if (!sPth.EndsWith("/"))
        {
            sPth += "/";
        }
        string sf = sPth + ResPath.GetResListTxt();

        if (File.Exists(sf))
        {
            try
            {
                FileStream stm = new FileStream(sf, FileMode.Open, FileAccess.Read);
                if (stm.Length > 0)
                {
                    byte[] vAry = new byte[stm.Length];
                    stm.Read(vAry, 0, vAry.Length);
                    Dictionary <string, ResPackItm> otbl = ResUtil.ReadResTable(vAry);
                    ntbl = ResUtil.ReplaceAndMergeResTable(tbl, otbl);
                }
                stm.Close();
            }
            catch (Exception exp)
            {
                Debug.LogWarning("CAN NOT Open file = " + sf + ", Msg = " + exp.Message);
            }
        }
        ResUtil.WriteResTable(sf, ntbl);
    }
コード例 #2
0
    // 测试本地资源是否存在
    static public bool LocalResExist()
    {
        string sPth = GetLocal();

        try
        {
            if (!Directory.Exists(sPth))
            {
                return(false);
            }
        }
        catch (Exception exp)
        {
            Debug.Log("LocalResExist() DirEr = " + sPth + ", Msg = " + exp.Message);
            return(false);
        }

        string sf = GetLocal(ResPath.GetResListTxt());

        try
        {
            if (File.Exists(sf))
            {
                return(true);
            }
        }
        catch (Exception exp)
        {
            Debug.Log("LocalResExist() File.DirEr = " + sf + ", Msg = " + exp.Message);
        }
        return(false);
    }
コード例 #3
0
    //--------------------------------------------------------------------------------------------
    // 下载需要的资源列表 [ 每次启动都要同步 ]
    void NtfDownLoadResList(bool bLcl)
    {
        if (Application.isEditor && !ForcePackage)
        {
            return;   // 编辑器直接读本地资源
        }
        SetLoading();
        mMsg = @"正在同步资源列表, ...";
        string szfNm = ResPath.GetResListTxt();
        string szUrl = ResPath.GetUrl(szfNm);
        string szLcl = ResPath.GetLocal(szfNm);

        if (bLcl)
        {
            mMsg = @"从本地读取资源列表, ...";
            Debug.LogWarning("Try local0, File = " + szLcl);
            mResDic = ResUtil.ReadResTable(szLcl);
            //if (mResDic != null)
            {// 构建资源与数据包的对应关系并下载
                BuildPackListAndDownLoad();
            }
            return;
        }
        mMsg = @"从网络读取资源列表, ...";
        mEntry.StartCoroutine(DownLoadResList(szUrl, szLcl));
    }