示例#1
0
 public ResConf(string text)
 {
     //LogFile.Log("res text:" + text);
     files  = new Dictionary <string, ResInfo>();
     server = false;
     if (!string.IsNullOrEmpty(text))
     {
         foreach (var item in text.Split('\n'))
         {
             //LogFile.Log(item);
             var resInfo = item.Split('|');
             //LogFile.Log(resInfo.ToString());
             if (2 == resInfo.Length)
             {
                 version = resInfo[1].TrimEnd();
             }
             else if (3 == resInfo.Length)
             {
                 ResInfo res = new ResInfo(resInfo);
                 files[res.path] = res;
             }
         }
         LogFile.Log("res file count:" + files.Keys.Count);
     }
 }
示例#2
0
 public WWWInfo(LuaTable table)
 {
     if (null != table)
     {
         Url        = table.RawGet <string, string>("url");
         TargetPath = table.RawGet <string, string>("target");
         try
         {
             Size = table.RawGet <string, long>("size");
         }
         catch (Exception ex)
         {
             LogFile.Log(Url + ";" + ex.Message);
         }
         LuaTable ht = table.RawGet <string, LuaTable>("headers");
         if (null != ht)
         {
             Headers = ht.ToDictTable <string, string>().ToDictionary();
             ht.Dispose();
             ht = null;
         }
         table.Dispose();
         table = null;
     }
 }
示例#3
0
        protected static bool _deregisterEvent(EventPairDic dic, string eventName, object obj)
        {
            monitorEnter(dic);

            EventPairList list = null;

            if (!dic.TryGetValue(eventName, out list))
            {
                LogFile.Log("_deregisterEvent do not have event named\"" + eventName + "\"");
                return(false);
            }

            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                Pair pair = list[count - i - 1];
                if (pair.obj == obj)
                {
                    list.Remove(pair);
                    break;
                }
            }

            monitorExit(dic);

            return(true);
        }
示例#4
0
 public void SetTriggers(LuaTable lua)
 {
     _clearLua();
     mTriggerTable = lua;
     triggers.Clear();
     if (null != lua)
     {
         int i = 0;
         foreach (EventTriggerType t in Enum.GetValues(typeof(EventTriggerType)))
         {
             int         idx      = i;
             LuaFunction function = null;
             try
             {
                 function = mTriggerTable.RawGet <EventTriggerType, LuaFunction>(t);
             }
             catch (Exception ex)
             {
                 LogFile.Log(ex.Message);
             }
             if (null != function)
             {
                 mFuncs.Add(function);
                 Entry entry = new Entry();
                 entry.eventID = t;
                 entry.callback.AddListener((BaseEventData data) =>
                 {
                     mFuncs[idx].Call(data);
                 });
                 triggers.Add(entry);
                 i += 1;
             }
         }
     }
 }
示例#5
0
 public virtual void CheckAppVer(Action <bool> callback)
 {
     LogFile.Log("Platform方法 CheckAppUpdate(Action<bool> callback) 待实现,请重载该方法!");
     if (null != callback)
     {
         callback(true);
     }
 }
示例#6
0
        /// <summary>
        /// 对比服务器配置文件,记录新的文件
        /// </summary>
        /// <param name="url">服务器地址 URL.</param>
        /// <param name="callback">Callback.</param>
        private void _compareNewFiles(string url, Action <long, string> callback)
        {
            if (null != callback)
            {
                if (GameConfig.UseAsb)
                {
                    string sUrl = _confUrl(url);
                    string pUrl = _confUrlWrite();

                    WWWTO streamWWW = WWWTO.ReadFileStr(sUrl, (rst, msg) =>
                    {
                        if (rst)
                        {
                            mServConf = new ResConf(msg);

                            WWWTO writableWWW = WWWTO.ReadFileStr(pUrl, (_rst, _msg) =>
                            {
                                if (_rst)
                                {
                                    //之前已经拷贝过资源
                                    mCurConf = new ResConf(_msg);
                                }
                                else
                                {
                                    mCurConf = new ResConf("");
                                }
                                mTotalSize = 0;
                                if (mServConf.CompareVer(mCurConf) > 0)
                                {
                                    mNewFiles = mServConf.GetUpdateFiles(mCurConf);
                                    foreach (var f in mNewFiles)
                                    {
                                        mTotalSize += f.size;
                                    }
                                    callback(mTotalSize, mServConf.version);
                                }
                                else
                                {
                                    LogFile.Log("没有检测到新版本资源,跳过更新步骤");
                                    callback(mTotalSize, "没有检测到新版本资源,跳过更新步骤");
                                }
                            }, null);
                            writableWWW.Start();
                        }
                        else
                        {
                            LogFile.Warn("资源配置文件" + sUrl + "丢失");
                            callback(-1, STR_CONFIG_MISSING);
                        }
                    }, null);
                    streamWWW.Start();
                }
                else
                {
                    callback(0, "不使用Assetbundle不用拷贝/下载资源");
                }
            }
        }
示例#7
0
 public void StartGameLogic()
 {
     //在资源更新完毕后再次初始化GameResMranager(正常的游戏逻辑会初始化两次GameResMranager)
     ResManager.Instance.Initialize(delegate()
     {
         LogFile.Log("启动Lua虚拟机:" + mLuaMgr);
         mLuaMgr.InitStart();
         mLuaNotifyFunc = mLuaMgr.GetFunction(GameDefine.STR_LUA_EVENT_FUNC);
     });
 }
示例#8
0
        protected override void init()
        {
            base.init();

            EventManager.registerToMain(STR_NOTIFY_FUNC, this, "UpdateDownloadView");
            if (null != Handler)
            {
                mTextVersions = Handler.GetCompByIndex <Text>(0);
                mTextInfo     = Handler.GetCompByIndex <Text>(1);
                mSlider       = Handler.GetCompByIndex <Slider>(2);
            }

            if (GameConfig.useAsb && GameConfig.checkUpdate)
            {
                GameUpManager.Instance.CheckLocalRes((bool rst, string msg) =>
                {
                    LogFile.Log("检测本地资源结果:" + rst);
                    if (rst)
                    {
                        GameUpManager.Instance.CheckAppVer((bool obj) =>
                        {
                            LogFile.Log("检测APP version资源结果:" + rst);
                            if (obj)
                            {
                                GameUpManager.Instance.CheckServerRes((bool _rst, string _msg) =>
                                {
                                    if (_rst)
                                    {
                                        startGameLogic();
                                    }
                                    else
                                    {
                                        LogFile.Error("服务器资源更新失败");
                                        //TODO:显示弹窗等
                                        startGameLogic();
                                    }
                                });
                            }
                            else
                            {
                                LogFile.Error("包内不含ResConf.bytes文件");
                            }
                        });
                    }
                    else
                    {
                        LogFile.Error("包内不含ResConf.bytes文件");
                    }
                });
            }
            else
            {
                startGameLogic();
            }
        }
示例#9
0
        public List <ResInfo> GetUpdateFiles(ResConf newConf = null)
        {
            //version = newConf.version;
            List <ResInfo> newFiles = new List <ResInfo>();
            Dictionary <string, ResInfo> of;
            Dictionary <string, ResInfo> nf;

            //如果跟空的比较就把自己记录的所有文件更新
            if (null == newConf)
            {
                of = new Dictionary <string, ResInfo>();
                nf = files;
            }
            else
            {
                int rst = CompareVer(newConf);
                if (-1 == rst)
                {
                    LogFile.Log("当newConf的版本号比较大");
                    //当newConf的版本号比较大
                    of = files;
                    nf = newConf.files;
                }
                else if (1 == rst)
                {
                    LogFile.Log("当自己的的版本号比较大");
                    //当自己的的版本号比较大
                    of = newConf.files;
                    nf = files;
                }
                else
                {
                    LogFile.Log("版本号相同");
                    //==0 版本号相同
                    return(newFiles);
                }
            }
            foreach (var item in nf)
            {
                ResInfo or;
                if (of.TryGetValue(item.Key, out or))
                {
                    if (or.crc == item.Value.crc)
                    {
                        continue;
                    }
                }
                newFiles.Add(item.Value);
                LogFile.Log("检测到 {0} 需要拷贝", item.Value.path);
            }

            return(newFiles);
        }
示例#10
0
        public static void EncodeLuaFile(string srcFile, string outFile, BuilderConfig config)
        {
            if (!srcFile.ToLower().EndsWith(".lua", StringComparison.Ordinal))
            {
                File.Copy(srcFile, outFile, true);
                return;
            }
            bool   isWin   = true;
            string luaexe  = string.Empty;
            string args    = string.Empty;
            string exedir  = string.Empty;
            string currDir = Directory.GetCurrentDirectory();
            string platStr = "/";

            if (BuildTarget.Android == config.target)
            {
                platStr = "_32/";
                //Debug.LogError(platStr);
            }
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                isWin  = true;
                luaexe = "luajit.exe";
                args   = "-b -g " + srcFile + " " + outFile;
                exedir = Application.dataPath.Replace("Assets", "") + "LuaEncoder/luajit" + platStr;
            }
            else if (Application.platform == RuntimePlatform.OSXEditor)
            {
                isWin  = false;
                luaexe = "./luajit";
                args   = "-b -g " + srcFile + " " + outFile;
                exedir = Application.dataPath.Replace("Assets", "") + "LuaEncoder/luajit_mac" + platStr;
            }
            Directory.SetCurrentDirectory(exedir);
            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
            info.FileName        = luaexe;
            info.Arguments       = args;
            info.WindowStyle     = System.Diagnostics.ProcessWindowStyle.Hidden;
            info.UseShellExecute = isWin;
            info.ErrorDialog     = true;
            LogFile.Log(info.FileName + " " + info.Arguments);

            System.Diagnostics.Process pro = System.Diagnostics.Process.Start(info);
            pro.WaitForExit();
            Directory.SetCurrentDirectory(currDir);
        }
示例#11
0
 public int CompareVer(ResConf other)
 {
     LogFile.Log("版本对比:[{0}] : [{1}]", version, other.version);
     if (null == other || string.IsNullOrEmpty(other.version))
     {
         LogFile.Log("跟空版本号对比,默认本版本号大");
         return(1);
     }
     if (Equals(version, other.version))
     {
         return(0);
     }
     return(VersionCode > other.VersionCode ? 1 : -1);
     //string[] selfVn = getVersionNums(version);
     //string[] otherVn = getVersionNums(other.version);
     //int sc = selfVn.Length;
     //int oc = otherVn.Length;
     ////以两个版本号短的部分来比较(多的部分是包体资源的版本号有.base后缀)
     //int rst = 0;
     //for (int i = 0; i < (sc < oc ? sc : oc); ++i)
     //{
     //    if (int.Parse(selfVn[i]) != int.Parse(otherVn[i]))
     //    {
     //        rst = int.Parse(selfVn[i]) > int.Parse(otherVn[i]) ? 1 : -1;
     //        break;
     //    }
     //}
     ////这种情况只出现在本地刚解压好包体内的资源,这个时候资源配置版本会多一个.base后缀
     ////如果前面的版本号相同则默认服务器的版本号大
     //if (0 == rst && 1 == Math.Abs(sc - oc))
     //{
     //    if (sc > oc && Equals(selfVn[sc - 1], STR_BASE))
     //    {
     //        rst = -1;
     //    }
     //    else if (sc < oc && Equals(otherVn[oc - 1], STR_BASE))
     //    {
     //        rst = 1;
     //    }
     //}
     //return rst;
 }
示例#12
0
 private void _refreshAll()
 {
     lock (mLockObj)
     {
         itemDatas.Clear();
         List <UIItemData> d = _getDatas(mList);
         itemDatas.AddRange(d);
         int size = itemDatas.Count - MaxLineNum;
         if (size > 0)
         {
             for (int i = 0; i < size; i++)
             {
                 itemDatas.RemoveAt(0);
             }
         }
         Handler.SetScrollViewData(1, itemDatas);
         //TODO:解决 refreshAll只会在有新的日志才能刷新的问题
         LogFile.Log("DebugView refreshAll:" + MinLogLevel.ToString());
     }
 }
示例#13
0
        void _onWriteableConf(bool rst, string msg)
        {
            if (rst)
            {
                //之前已经拷贝过资源
                mWriteableConf = new ResConf(msg);
            }
            else
            {
                mWriteableConf = new ResConf("");
            }

            mCurConf = mWriteableConf;

            if (mStreamConf.CompareVer(mWriteableConf) > 0)
            {
                List <ResInfo> list = mStreamConf.GetUpdateFiles(mWriteableConf);
                if (list.Count > 0)
                {
                    //将可读写文件夹下的老版本资源删除
                    for (int i = 0; i < list.Count; i++)
                    {
                        ResInfo ri       = list[i];
                        string  savePath = Tools.GetWriteableDataPath(GameConfig.STR_ASB_MANIFIST + "/" + ri.path);
                        if (File.Exists(savePath))
                        {
                            File.Delete(savePath);
                            LogFile.Log("删除已下载的老资源:" + savePath);
                        }
                        mCurConf.files[ri.path] = mStreamConf.files[ri.path];
                    }
                }
                mCurConf.version = mStreamConf.version;
                //保存新的资源版本号
                saveVersionCode();
                mCurConf.SaveToFile(_confPathWrite());
            }
            _callbackLocal(true, "");
        }
示例#14
0
 /// <summary>
 /// Installs the new app.安卓安装apk,ios跳转到商店
 /// </summary>
 /// <param name="path">Path.</param>
 public virtual void InstallNewApp(string path)
 {
     LogFile.Log("Platform方法 InstallNewApp(string path) 待实现,请重载该方法!\npath:{0}", path);
 }
示例#15
0
 /// <summary>
 /// TODO:待实现
 /// </summary>
 /// <param name="delaySec">Delay sec.</param>
 public virtual void Restart(float delaySec)
 {
     LogFile.Log("Platform方法 Restart(float delaySec) 待实现,请重载该方法!\ndelaySec:{0}", delaySec);
 }
示例#16
0
 public virtual void TakeImageAlbum()
 {
     LogFile.Log("Platform方法 TakeAlbum() 待实现,请重载该方法!");
 }
示例#17
0
 public virtual void SetNotifySplitStr(string s)
 {
     LogFile.Log("Platform方法 SetNotifySplitStr(string s) 待实现,请重载该方法!\ns:{0}", s);
 }
示例#18
0
        private void downloadNextUrl()
        {
            mIdx += 1;
            LogFile.Log("startDownload:" + Urls[mIdx]);
            Tools.CheckDirExists(Directory.GetParent(SavePath).FullName, true);
            if (mIdx >= 0 && mIdx < Urls.Count)
            {
                LogFile.Log("下载:" + Urls[mIdx]);
                if (null != mRequest)
                {
                    mRequest.Abort();
                }
                mRequest = (HttpWebRequest)WebRequest.Create(Urls[mIdx]);
                mRequest.ReadWriteTimeout = 500;
                mRequest.Timeout          = 500;

                try
                {
                    HttpWebResponse response = (HttpWebResponse)mRequest.GetResponse();
                    mTotalSize      = response.ContentLength;
                    mPartialEnabled = response.StatusCode == HttpStatusCode.PartialContent;
                    LogFile.Log("服务器是否允许部分下载:" + mPartialEnabled);
                    if (ThreadNum > 1 && !mPartialEnabled)
                    {
                        ThreadNum = 1;
                        LogFile.Log("资源服不支持部分下载,取消多线程下载。");
                    }
                }
                catch (Exception ex)
                {
                    LogFile.Log("error =>> " + ex.Message);
                    mRequest.Abort();
                    mRequest = null;
                    downloadNextUrl();
                    return;
                }

                mPartSize     = new long[ThreadNum];
                mPartDoneSize = new long[ThreadNum];
                mPartStartPos = new long[ThreadNum];

                for (int i = 0; i < ThreadNum; i++)
                {
                    int _i = i;
                    //double
                    mPartSize[i] = mTotalSize / ThreadNum + ((i == ThreadNum - 1) ? mTotalSize % ThreadNum : 0);
                    if (i > 0)
                    {
                        mPartStartPos[i] = mPartStartPos[i - 1] + mPartSize[i - 1];
                    }
                    else
                    {
                        mPartStartPos[0] = 0;
                    }

                    Loom.RunAsync(() =>
                    {
                        onRecive(_i);
                    });
                }

                if (mCoroutine == 0)
                {
                    //GameCoroutineManager.Instance.StopCor(mCoroutine);
                    mCoroutine = GameCoroutineManager.Instance.StartCor(onProgress());
                }
            }
            else
            {
                //TODO:回调
            }
        }
示例#19
0
        /// <summary>
        /// 加载asb可以从streaming路径加载,不需要将资源拷贝到可读写文件夹
        /// 当包体资源有更新时,删除老的资源包
        /// </summary>
        /// <param name="srcUrl">Source URL.</param>
        /// <param name="tarUrl">Tar URL.</param>
        /// <param name="callback">Callback.</param>
        private void delOldWriteableRes(string srcUrl, string tarUrl, Action <bool, string> callback)
        {
            string confPath = STR_RES_CONF;

            if (null != callback)
            {
                ResConf srcConf = null;
                ResConf tarConf = null;

                if (GameConfig.useAsb)
                {
                    string sUrl = Tools.PathCombine(srcUrl, confPath);
                    string pUrl = Tools.PathCombine(tarUrl, confPath);

                    TimeOutWWW streamWWW = getTimeOutWWW();
                    streamWWW.ReadFileStr("localResConf", sUrl, 1f, (rst, msg) =>
                    {
                        if (rst)
                        {
                            srcConf = new ResConf(msg);

                            TimeOutWWW writableWWW = getTimeOutWWW();
                            writableWWW.ReadFileStr("externalResConf", pUrl, 1f, (_rst, _msg) =>
                            {
                                if (_rst)
                                {
                                    //之前已经拷贝过资源
                                    tarConf = new ResConf(_msg);
                                }
                                else
                                {
                                    tarConf = new ResConf("");
                                }

                                curConf = tarConf;

                                if (srcConf.CompareVer(tarConf) > 0)
                                {
                                    List <ResInfo> list = srcConf.GetUpdateFiles(tarConf);
                                    if (list.Count > 0)
                                    {
                                        //将可读写文件夹下的老版本资源删除
                                        for (int i = 0; i < list.Count; i++)
                                        {
                                            ResInfo ri      = list[i];
                                            string savePath = Tools.GetWriteableDataPath(GameConfig.STR_ASB_MANIFIST + "/" + ri.path);
                                            if (File.Exists(savePath))
                                            {
                                                File.Delete(savePath);
                                                LogFile.Log("删除已下载的老资源:" + savePath);
                                            }
                                            curConf.files[ri.path] = srcConf.files[ri.path];
                                        }
                                    }
                                    curConf.version = srcConf.version;
                                    //保存新的资源版本号
                                    GameConfig.SetInt(GameDefine.STR_CONF_KEY_RES_VER_I, curConf.VersionCode);
                                    curConf.SaveToFile(Tools.GetWriteableDataPath(GameConfig.STR_ASB_MANIFIST + "/" + STR_RES_CONF));
                                    mVersionStr = "app:v" + Application.version + " res" + curConf.version;
                                    refreshUI(100);
                                }
                            }, null);
                        }
                    }, null);
                }
                callback(true, "");
            }
        }
示例#20
0
 public virtual string GetFirstClipboard()
 {
     LogFile.Log("Platform方法 GetFirstClipboard() 待实现,\n默认使用GUIUtility.systemCopyBuffer,\n请重载该方法!");
     return(GUIUtility.systemCopyBuffer);
 }
示例#21
0
 public virtual void SetNoticeObFunc(string gameobjName, string funcName)
 {
     LogFile.Log("Platform方法 SetNoticeObFunc(string gameobjName, string funcName) 待实现,请重载该方法!\nobjName:{0},funcName{1}", gameobjName, funcName);
 }
示例#22
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="asbName">Asb name.</param>
        /// <param name="sceneName">Scene name.</param>
        /// <param name="sync">If set to <c>true</c> sync.</param>
        /// <param name="add">If set to <c>true</c> add.</param>
        /// <param name="callback">Callback.</param>
        /// <param name="luaFunc">Lua func.</param>
        public void LoadScene(string asbName, string sceneName, bool sync, bool add, Action <float> callback = null, LuaFunction luaFunc = null)
        {
            if (sceneName.Equals(""))
            {
                sceneName = ".unity";
            }
            string        scenePath = Tools.GetResInAssetsName(asbName, sceneName);
            LoadSceneMode mode      = add ? LoadSceneMode.Additive : LoadSceneMode.Single;

#if UNITY_EDITOR
            if (!GameConfig.UseAsb)
            {
                //Tools.RelativeTo(Tools.GetResPath(Tools.PathCombine(asbName, sceneName)), Application.dataPath, true);
                //Debug.LogWarning(scenePath);
                int index = SceneUtility.GetBuildIndexByScenePath(scenePath);
                //Debug.LogWarning(index);

                bool   hasSceneLoad = index >= 0;
                string loadName     = "";
                if (hasSceneLoad)
                {
                    loadName = SceneUtility.GetScenePathByBuildIndex(index);
                }
                _loadScene(sync, mode, loadName, hasSceneLoad, callback, luaFunc);
                return;
            }
#endif
            LoadRes <UObj>(asbName, string.Empty
                           , delegate(UObj obj)
            {
                if (obj != null)
                {
                    LogFile.Log(obj.ToString());
                }
                AssetBundleInfo info = GetLoadedAssetBundle(Tools.GetAsbName(asbName));
                bool rst             = false;
                string loadName      = "";

                if (null != info)
                {
                    string[] scenes = info.m_AssetBundle.GetAllScenePaths();
                    for (int i = 0; i < scenes.Length; ++i)
                    {
                        string s = scenes[i];
                        //LogFile.Log("Scenename {0}: {1}, inputName:{2}", i, s, scenePath);
                        if (s.Equals(scenePath))
                        {
                            loadName = s;
                            //SceneManager.LoadScene(s, mode);
                            rst = true;
                            //LogFile.Log("找到名字相同的scene,break");
                            break;
                        }
                    }
                    if (!rst)
                    {
                        LogFile.Error("LoadScene加载Assetbundl:{0},查找{1}失败!!", asbName, scenePath);
                    }
                }
                else
                {
                    LogFile.Error("LoadScene找不到Assetbundle:{0}", asbName);
                }
                _loadScene(sync, mode, loadName, rst, callback, luaFunc);
            });
        }
示例#23
0
 /// <summary>
 /// 请求支付订单
 /// </summary>
 /// <param name="pid">支付id</param>
 /// <param name="externalData">额外数据</param>
 public virtual void StartPurchase(string pid, string externalData)
 {
     LogFile.Log("Platform方法 StartPurchase(string pid, string externalJsonData) 待实现,请重载该方法!\npid:{0}, ejd:{1}", pid, externalData);
 }
示例#24
0
        /// <summary>
        /// 对比resConf.bytes文件,根据需要进行拷贝或下载
        /// </summary>
        /// <param name="srcUrl">Source URL.</param>
        /// <param name="tarUrl">Tar URL.</param>
        /// <param name="callback">Callback.</param>
        private void checkResConf(string srcUrl, string tarUrl, Action <bool, string> callback)
        {
            string confPath = STR_RES_CONF;

            if (null != callback)
            {
                ResConf srcConf = null;
                ResConf tarConf = null;

                if (GameConfig.useAsb)
                {
                    string sUrl = Tools.PathCombine(srcUrl, confPath);
                    string pUrl = Tools.PathCombine(tarUrl, confPath);

                    TimeOutWWW streamWWW = getTimeOutWWW();
                    streamWWW.ReadFileStr("localResCOnf", sUrl, 1f, (rst, msg) =>
                    {
                        if (rst)
                        {
                            srcConf = new ResConf(msg);

                            TimeOutWWW writableWWW = getTimeOutWWW();
                            writableWWW.ReadFileStr("externalResConf", pUrl, 1f, (_rst, _msg) =>
                            {
                                if (_rst)
                                {
                                    //之前已经拷贝过资源
                                    tarConf = new ResConf(_msg);
                                }
                                else
                                {
                                    tarConf = new ResConf("");
                                }

                                curConf       = tarConf;
                                float last    = Time.time;
                                long lastSize = 0;

                                if (srcConf.CompareVer(tarConf) > 0)
                                {
                                    List <ResInfo> list = srcConf.GetUpdateFiles(tarConf);
                                    if (list.Count > 0)
                                    {
                                        string format = Lm.GetStr("正在下载资源,已完成[ {0} / {1} ],下载速度:{2} ...");
                                        mInfoStr      = string.Format(format, 0, list.Count, "0Byte/s");
                                        //需要拷贝资源到可读写文件夹
                                        TimeOutWWW copyLocal = getTimeOutWWW();
                                        List <WWWInfo> infos = new List <WWWInfo>();
                                        long totalSize       = 0;
                                        for (int i = 0; i < list.Count; ++i)
                                        {
                                            ResInfo ri      = list[i];
                                            string url      = Tools.PathCombine(srcUrl, ri.path);
                                            string savePath = Tools.GetWriteableDataPath(GameConfig.STR_ASB_MANIFIST + "/" + ri.path);
                                            totalSize      += ri.size;
                                            infos.Add(new WWWInfo(url, savePath, ri.size));
                                        }
                                        string totalSizeStr = Tools.FormatMeroySize(totalSize);
                                        copyLocal.DownloadFiles("copyLocal", infos, 2f, (string noticeKey, double progress, int index, string __msg) =>
                                        {
                                            //LogFile.Log("progress:{0}; index:{1}; msg:{2};", progress, index, __msg);

                                            if (progress.Equals(1d))
                                            {
                                                if (__msg.Equals(TimeOutWWW.STR_SUCCEEDED))
                                                {
                                                    curConf.version = srcConf.version;
                                                    //保存新的资源版本号
                                                    GameConfig.SetInt(GameDefine.STR_CONF_KEY_RES_VER_I, curConf.VersionCode);
                                                    mVersionStr = "app:v" + Application.version + " res" + curConf.version;
                                                    refreshUI(100);
                                                    //拷贝完成
                                                    callback(true, "资源更新完成");
                                                }
                                                else
                                                {
                                                    callback(false, "部分资源更新失败");
                                                }
                                                curConf.SaveToFile(Tools.GetWriteableDataPath(GameConfig.STR_ASB_MANIFIST + "/" + STR_RES_CONF));

                                                return;
                                            }
                                            if (progress.Equals(-1d))
                                            {
                                                //有文件下载或者拷贝失败
                                                LogFile.Warn("[" + infos[index].Url + "]拷贝或下载失败");
                                            }
                                            else
                                            {
                                                if (__msg.Equals(TimeOutWWW.STR_DONE))
                                                {
                                                    //有文件下载成功
                                                    curConf.files[list[index - 1].path] = srcConf.files[list[index - 1].path];

                                                    //mInfoStr = string.Format(format, index, list.Count);
                                                }
                                                float now       = Time.time;
                                                float dt        = now - last;
                                                long doneSize   = (long)(totalSize * progress);
                                                long siezPerSec = (long)((doneSize - lastSize) / dt);
                                                if (siezPerSec > 0)
                                                {
                                                    mInfoStr = string.Format(format, Tools.FormatMeroySize(doneSize), totalSizeStr, Tools.FormatMeroySize(siezPerSec) + "/s");
                                                    //LogFile.Log(mInfoStr);
                                                    refreshUI((float)progress);
                                                }
                                                last     = now;
                                                lastSize = doneSize;
                                            }
                                        }, null);
                                    }
                                }
                                else
                                {
                                    LogFile.Log("没有检测到新版本资源,跳过更新步骤");
                                    callback(true, "没有检测到新版本资源,跳过更新步骤");
                                }
                            }, null);
                        }
                        else
                        {
                            LogFile.Warn("资源配置文件" + sUrl + "丢失");
                            callback(false, STR_CONFIG_MISSING);
                        }
                    }, null);
                }
                else
                {
                    callback(true, "不使用Assetbundle不用拷贝/下载资源");
                }
            }
        }
示例#25
0
 /// <summary>
 /// 单例组件被销毁时调用,子类可派生
 /// </summary>
 public virtual bool Dispose()
 {
     LogFile.Log("clearComp:" + typeof(T));
     return(true);
 }
示例#26
0
        void _download()
        {
            if (mTotalSize == 0 || mIsDownloading)
            {
                LogFile.Log(mPkgName + " 正在下载,不用重复下载。");
                return;
            }
            string srcUrl   = _getServUrl();
            float  last     = Time.time;
            long   lastSize = 0L;

            if (null != mNewFiles && mNewFiles.Count > 0)
            {
                List <WWWInfo> infos = new List <WWWInfo>();
                for (int i = 0; i < mNewFiles.Count; ++i)
                {
                    ResInfo ri       = mNewFiles[i];
                    string  url      = Tools.PathCombine(srcUrl, ri.path);
                    string  savePath = Tools.GetWriteableDataPath(GameConfig.STR_ASB_MANIFIST + "/" + ri.path);
                    infos.Add(new WWWInfo(url, savePath, ri.size));
                }

                //需要拷贝资源到可读写文件夹
                mDownloader = WWWTO.DownloadFiles(
                    infos,
                    (double progress, int index, string msg) =>
                {
                    if (Tools.Equals(progress, 1d))
                    {
                        if (msg.Equals(WWWTO.STR_SUCCEEDED))
                        {
                            mCurConf.version = mServConf.version;
                            //保存新的资源版本号
                            saveVersionCode();
                            _callbackDownload(1d, 0, msg);
                        }
                        else
                        {
                            _callbackDownload(1d, -1, msg);
                        }

                        mCurConf.SaveToFile(_confPathWrite());
                        mIsDownloading = false;
                    }
                    else
                    {
                        string filePath = mNewFiles[index - 1].path;
                        if (Tools.Equals(progress, -1d))
                        {
                            //有文件下载失败
                            LogFile.Warn("[" + filePath + "]下载失败,url:" + infos[index - 1].Url);
                        }
                        else
                        {
                            if (msg.Equals(WWWTO.STR_DONE))
                            {
                                //有文件下载成功
                                mCurConf.files[filePath] = mServConf.files[filePath];
                            }
                            float now       = Time.time;
                            float dt        = now - last;
                            long doneSize   = (long)(mTotalSize * progress);
                            long sizePerSec = (long)((doneSize - lastSize) / dt);
                            if (sizePerSec >= 0)
                            {
                                _callbackDownload(progress, sizePerSec, filePath);
                            }
                            last     = now;
                            lastSize = doneSize;
                        }
                    }
                },
                    null
                    );
                mDownloader.Start();
                mIsDownloading = true;
            }
        }
示例#27
0
 public virtual void Copy2Clipboard(string content)
 {
     GUIUtility.systemCopyBuffer = content;
     LogFile.Log("Platform方法 Copy2Clipboard(string content) 待实现,\n默认使用GUIUtility.systemCopyBuffer,\n请重载该方法!");
 }
示例#28
0
 public override void TakeImageAlbum()
 {
     LogFile.Log("TakeAlbum");
 }
示例#29
0
 public virtual void test2()
 {
     LogFile.Log("Platform方法 test2() 待实现,请重载该方法!");
 }
示例#30
0
 public override void TakeImagePhoto()
 {
     LogFile.Log("TakePhoto");
 }