Ejemplo n.º 1
0
    //public IEnumerator OnExtractResource()
    //{
    //    timeCount = Time.realtimeSinceStartup;


    //    string dataPath = IPathTools.GetAssetPersistentPath() + "/";  //数据目录
    //    string resPath = IPathTools.GetWWWStreamPath() + "StreamingAssets.zip";
    //    WWW tmp = new WWW(resPath);


    //    yield return tmp;

    //    MemoryStream memStream = new MemoryStream(tmp.bytes.Length);

    //    FileStream output = new FileStream(dataPath, FileMode.Create);

    //    SevenZip.Compression.LZMA.Encoder coder = new SevenZip.Compression.LZMA.Encoder();

    //    DataOver();

    //}


    public IEnumerator OnExtractResource()
    {
        if (!File.Exists(IPathTools.GetAssetPersistentPath() + "/" + GloableConfig.LuaFileListName))
        {
            willCopyAsset = true;
        }
        else
        {
            willCopyAsset = false;

            //yield return LoadText ();
        }



        if (willCopyAsset)
        {
            timeCount = Time.realtimeSinceStartup;


            string zipPath  = Application.temporaryCachePath + "/tempZip.zip";
            string dataPath = IPathTools.GetAssetPersistentPath() + "/";              //数据目录
            string resPath  = IPathTools.GetWWWStreamPath() + "StreamingAssets.zip";  //游戏包资源目录
            Debuger.Log("dataPath  ==" + dataPath);
            Debuger.Log("resPath  ==" + resPath);

            WWW www = new WWW(resPath);
            yield return(www);

            var data = www.bytes;
            File.WriteAllBytes(zipPath, data);

            try
            {
                ZipUtil.Unzip(zipPath, dataPath);
            }
            catch (System.Exception e)
            {
                Debuger.Log(" e ===" + e);
            }



            yield return(null);
        }


        Debuger.Log("Finish  copy zip ==");
        DataOver();
    }