示例#1
0
        static int _m_AppContentPath_xlua_st_(RealStatePtr L)
        {
            try {
                {
                    string __cl_gen_ret = PathTools.AppContentPath(  );
                    LuaAPI.lua_pushstring(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
示例#2
0
    IEnumerator OnExtractResource()
    {
        string dataPath = PathTools.DataPath;          //数据目录

        Debug.Log("解包存放地址:>" + dataPath);
        string resPath = PathTools.AppContentPath();         //游戏包资源目录

        if (Directory.Exists(dataPath))
        {
            Directory.Delete(dataPath, true);
        }
        Directory.CreateDirectory(dataPath);

        string infile  = resPath + "files.txt";
        string outfile = dataPath + "files.txt";


        if (File.Exists(outfile))
        {
            File.Delete(outfile);
        }

        AssetCheckData data = new AssetCheckData();

        data.msg   = "比较资源中";
        data.value = 0f;

        UnityTools.LogMust("正在解包文件:>" + infile);
        UIManager.Intance.SendMsg(WindowID.AssetCheckUI, WindowMsgID.ShowLoadingTips, data);
        UnityTools.LogMust(infile);
        UnityTools.LogMust(outfile);
        if (Application.platform == RuntimePlatform.Android)
        {
            WWW www = new WWW(infile);
            yield return(www);

            if (www.isDone)
            {
                File.WriteAllBytes(outfile, www.bytes);
            }
            yield return(0);
        }
        else
        {
            File.Copy(infile, outfile, true);
        }
        yield return(new WaitForEndOfFrame());

        //释放所有文件到数据目录
        string[] files = File.ReadAllLines(outfile);
        int      idx   = 0;

        foreach (var file in files)
        {
            string[] fs = file.Split('|');
            infile  = resPath + fs[0];             //
            outfile = dataPath + fs[0];

            data.msg = "解压文件, 不耗流量" + idx.ToString() + "/" + files.Length.ToString();
            idx++;
            data.value = (float)(idx - 1) / (float)files.Length;

            UnityTools.LogMust("正在拷贝文件:>" + data.value + " ,  " + infile);
            UIManager.Intance.SendMsg(WindowID.AssetCheckUI, WindowMsgID.ShowLoadingTips, data);

            string dir = Path.GetDirectoryName(outfile);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(infile);
                yield return(www);

                if (www.isDone)
                {
                    File.WriteAllBytes(outfile, www.bytes);
                }
                yield return(0);
            }
            else
            {
                if (File.Exists(outfile))
                {
                    File.Delete(outfile);
                }
                File.Copy(infile, outfile, true);
            }
            yield return(new WaitForEndOfFrame());
        }

        UnityTools.LogMust("拷贝完成!!!");
        data.value = 0.0f;
        data.msg   = "版本检测";
        UIManager.Intance.SendMsg(WindowID.AssetCheckUI, WindowMsgID.ShowLoadingTips, data);
        yield return(new WaitForSeconds(0.1f));

        //释放完成,开始启动更新资源
        UIManager.Intance.SendMsg(WindowID.AssetCheckUI, WindowMsgID.ShowLoadingTips, data);
        if (GameManager.Instance.bOpenExtract_Zip)
        {
            yield return(StartCoroutine(UnZip()));

            data.value = 0f;
            data.msg   = "版本检测, 请耐心等待..";
            UnityTools.LogMust("解压完成!!!");
            UIManager.Intance.SendMsg(WindowID.AssetCheckUI, WindowMsgID.ShowLoadingTips, data);
        }

        HandleEndExtract();
    }
示例#3
0
        IEnumerator CopyToPersistentDataPath()
        {
            string dataPath = Application.persistentDataPath;       //Util.DataPath;  //数据目录
            string resPath  = PathTools.AppContentPath();           //Util.AppContentPath(); //游戏包资源目录

            if (Directory.Exists(dataPath))
            {
                Directory.Delete(dataPath, true);
            }
            Directory.CreateDirectory(dataPath);

            string infile  = resPath + "md5filelist.txt";
            string outfile = dataPath + "md5filelist.txt";

            if (File.Exists(outfile))
            {
                File.Delete(outfile);
            }

            string message = "正在解包文件:>files.txt";

            Debug.Log(infile);
            Debug.Log(outfile);

            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(infile);

                while (true)
                {
                    if (www.isDone || !string.IsNullOrEmpty(www.error))
                    {
                        System.Threading.Thread.Sleep(50);
                        if (!string.IsNullOrEmpty(www.error))
                        {
                            Debug.LogError(www.error);
                        }
                        else
                        {
                            File.WriteAllBytes(outfile, www.bytes);
                        }
                        break;
                    }
                }
                yield return(0);
            }
            else
            {
                File.Copy(infile, outfile, true);
            }
            yield return(new WaitForEndOfFrame());

            //释放所有文件到数据目录
            string[] files = File.ReadAllLines(outfile);
            foreach (var file in files)
            {
                string[] fs = file.Split('=');

                if (fs.Length == 1)
                {
                    Debug.LogWarning("跳过 >>" + file);
                    continue;
                }

                if (resPath.EndsWith("/") && fs [0].StartsWith("/"))
                {
                    resPath = resPath.Substring(0, resPath.Length - 1);
                }

                if (dataPath.EndsWith("/") && fs [0].StartsWith("/"))
                {
                    dataPath = dataPath.Substring(0, dataPath.Length - 1);
                }

                infile  = resPath + fs[0];                   //
                outfile = dataPath + fs[0];

                message = "正在解包文件:>" + fs[0];
                Debug.Log("正在解包文件:>" + infile);

                string dir = Path.GetDirectoryName(outfile);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (Application.platform == RuntimePlatform.Android)
                {
                    WWW www = new WWW(infile);

                    while (true)
                    {
                        if (www.isDone || !string.IsNullOrEmpty(www.error))
                        {
                            System.Threading.Thread.Sleep(50);
                            if (!string.IsNullOrEmpty(www.error))
                            {
                                Debug.LogError(www.error);
                            }
                            else
                            {
                                File.WriteAllBytes(outfile, www.bytes);
                                Debug.LogWarning(">>" + outfile + ">>" + www.bytes.Length);
                            }
                            break;
                        }
                    }

                    /*
                     * yield return www;
                     *
                     * if (www.isDone) {
                     *      File.WriteAllBytes(outfile, www.bytes);
                     *      Debug.LogWarning (">>" + outfile+">>"+www.bytes.Length);
                     * }
                     */
                    yield return(0);
                }
                else
                {
                    if (File.Exists(outfile))
                    {
                        File.Delete(outfile);
                    }
                    File.Copy(infile, outfile, true);
                }
                yield return(new WaitForEndOfFrame());
            }
            message = "解包完成!!!";

            luaManager = LuaManager.GetInstance();
            luaManager.InitDoString = "require 'lua/game/GameState' \n game_state_init() \n";
            env = luaManager.LuaEnvGetOrNew();

            yield return(new WaitForSeconds(1f));

            RunState();

            isCopyCmp = true;
        }
示例#4
0
    public UpdateInfo GetUpdateInfo(string content)
    {
        UpdateInfo info = new UpdateInfo();

        string[] files  = content.Split('\n');
        string   random = DateTime.Now.ToString("yyyymmddhhmmss");

        for (int i = 0; i < files.Length; i++)
        {
            //优先判断是否存在于datapath,如果存在则读取,不存在尝试读取streamingassts目录
            if (string.IsNullOrEmpty(files[i]))
            {
                continue;
            }
            string[] keyValue      = files[i].Split('|');
            string   f             = keyValue[0];
            string   dataLocalFile = (PathTools.DataPath + f).Trim();
            string   localfile     = dataLocalFile;
            string   path          = Path.GetDirectoryName(localfile);
            if (!Directory.Exists(path))
            {
                string contentLocalFile = (PathTools.AppContentPath() + f).Trim();
                string contentpath      = Path.GetDirectoryName(contentLocalFile);
                if (!Directory.Exists(contentpath))
                {
                    Directory.CreateDirectory(path);
                }
                else
                {
                    localfile = contentLocalFile;
                }
            }
            string fileUrl   = url + f + "?v=" + random;
            bool   canUpdate = !File.Exists(localfile);
            //本地存在文件
            if (!canUpdate)
            {
                string remoteMd5 = keyValue[1].Trim();
                string localMd5  = MD5Tools.md5file(localfile);
                canUpdate = !remoteMd5.Equals(localMd5);
                if (canUpdate)
                {
                    File.Delete(localfile);
                }
            }
            //本地缺少文件
            if (canUpdate)
            {
                if (fileUrl.Contains(AppConst.DllName) && Application.platform == RuntimePlatform.Android)
                {
                    info.bRestart = true;
                }
                if (!fileUrl.Contains("manifest"))
                {
                    info.totalSize += GetHttpFileSize(fileUrl);
                }
                UnityTools.LogMust("需要更新:" + fileUrl);
                info.dict[dataLocalFile] = fileUrl;
            }
        }
        return(info);
    }
示例#5
0
    /// <summary>
    /// 初始化
    /// </summary>
    static public void Init()
    {
        SetPath();

        string md5filelist = "md5filelist.txt";

        string dataPath = assetsUpdatePath;           //Util.DataPath;  //数据目录
        string resPath  = PathTools.AppContentPath(); //Util.AppContentPath(); //游戏包资源目录

        string localMD5BakFilePath = PathTools.Combine(dataPath, "/md5filelist.txt.bak");

        string infile  = PathTools.Combine(resPath, "md5filelist.txt");
        string outfile = PathTools.Combine(dataPath, "md5filelist.txt");

        Debug.Log(infile);

        if (PathTools.ExistsPersistentPath("md5filelist.txt"))
        {
            Debug.LogWarning("非首次启动!");
        }
        else
        {
            Debug.LogWarning("首次启动!");

            if (!Directory.Exists(dataPath))
            {
                Directory.CreateDirectory(dataPath);
            }

            Debug.LogErrorFormat("localMD5BakFilePath {0} {1}", localMD5BakFilePath, File.Exists(localMD5BakFilePath));

            if (File.Exists(localMD5BakFilePath))
            {
                Debug.LogErrorFormat("本地列表文件 bak 存在!{0}", localMD5BakFilePath);
                File.Delete(localMD5BakFilePath);
            }
            if (File.Exists(localMD5BakFilePath))
            {
                Debug.LogErrorFormat("本地列表文件 bak 删除成功!{0}", localMD5BakFilePath);
            }

            string message = "正在解包文件:>md5filelist.txt";

            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(infile);

                while (true)
                {
                    if (www.isDone || !string.IsNullOrEmpty(www.error))
                    {
                        System.Threading.Thread.Sleep(50);
                        if (!string.IsNullOrEmpty(www.error))
                        {
                            Debug.LogError(www.error);
                        }
                        else
                        {
                            File.WriteAllBytes(outfile, www.bytes);
                            Debug.LogWarning(">>" + outfile);
                        }
                        break;
                    }
                }
            }
            else
            {
                File.Copy(infile, outfile, true);
            }
        }

        string path = PathTools.Combine(PathTools.PersistentDataPath(), md5filelist);

        Debug.LogWarningFormat("热更新步骤 1 【初始化拷贝】完成!{0} {1}", path, System.IO.File.Exists(path));
    }