private void OnLoadDataTableComplete(object param) { GameEntry.Log(LogCategory.Normal, "加载c#表格完毕"); //执行Lua初始化 GameEntry.Lua.Init(); }
public void OnUpdate() { if (Time.time > m_NextClearTime + ClearInterval) { //类对象池该释放了 m_NextClearTime = Time.time; PoolManager.ClearClassObjectPool(); GameEntry.Log(LogCategory.Normal, "释放类对象池"); } if (Time.time > m_ReleaseResourceNextRunTime + ReleaseResourceInterval) { //资源池该释放了 m_ReleaseResourceNextRunTime = Time.time; PoolManager.ReleaseAssetBundlePool(); GameEntry.Log(LogCategory.Normal, "释放AssetBundle池"); } if (Time.time > m_ReleaseAssetNextRunTime + ReleaseAssetInterval) { //资源池该释放了 m_ReleaseAssetNextRunTime = Time.time; PoolManager.ReleaseAssetPool(); Resources.UnloadUnusedAssets(); GameEntry.Log(LogCategory.Normal, "释放Asset池"); } }
public override void OnEnable() { base.OnEnable(); GameEntry.Log(LogCategory.Procedure, "OnEnable ProcedureLogOn"); GameEntry.UI.OpenUIForm(UIFormId.UI_Task); }
public override void OnEnable() { base.OnEnable(); GameEntry.Log(LogCategory.Procedure, "OnEnable ProcedureCheckVersion"); GameEntry.Resource.InitStreamingAssetsBundleInfo(); //GameEntry.Procedure.ChangeState(ProcedureState.Preload); }
/// <summary> /// 将只读区版本文件初始化到可写区 /// </summary> private void InitVersionFileFormStreamingAssetsToLocal() { GameEntry.Log(LogCategory.Resource, "InitVersionFileFormStreamingAssetsToLocal"); m_LocalAssetsVersionDic = new Dictionary <string, AssetBundleInfoEntity>(); var enumerator = m_StreamingAssetsVersionDic.GetEnumerator(); while (enumerator.MoveNext()) { AssetBundleInfoEntity entity = enumerator.Current.Value; m_LocalAssetsVersionDic[enumerator.Current.Key] = new AssetBundleInfoEntity() { AssetBundleName = entity.AssetBundleName, MD5 = entity.MD5, Size = entity.Size, IsFirstData = entity.IsFirstData, IsEncrypt = entity.IsEncrypt }; } //保存版本文件 LocalAssetManager.SaveVersionFile(m_LocalAssetsVersionDic); //保存版本号 m_LocalAssetsVersion = m_StreamingAssetsVersion; LocalAssetManager.SetResourceVersion(m_LocalAssetsVersion); }
/// <summary> /// 检查更新 /// </summary> private void CheckVersionChange() { GameEntry.Log(LogCategory.Resource, "CheckVersionChange"); if (LocalAssetManager.GetVersionFileExists()) { //判断只读区资源版本号和CDN资源版本号 if (m_StreamingAssetsVersion.Equals(m_CDNVersion)) { GameEntry.Log(LogCategory.Resource, "只读区资源版本号和CDN资源版本号一致"); //一致,直接进入预加载流程 GameEntry.Procedure.ChangeState(ProcedureState.Preload); } else { GameEntry.Log(LogCategory.Resource, "只读区版本号和CDN版本号不一致"); //TODO: 不一致 开始检查更新 //最后进入预加载流程 } } else { //下载初始资源 DownloadInitResource(); } }
private void OnLoadDataTableComplete(object param) { GameEntry.Log(LogCategory.Normal, "加载c#表格完毕"); #if !DISABLE_ASSETBUNDLE //执行Lua初始化 GameEntry.Lua.Init(); #endif }
/// <summary> /// 初始化CDN资源包信息 /// </summary> private void InitCDNAssetBundleInfo() { GameEntry.Log(LogCategory.Resource, "InitCDNAssetBundleInfo"); string url = string.Format("{0}VersionFile.bytes", GameEntry.Data.SysDataManager.CurrChannelConfig.RealSourceUrl); GameEntry.Log(LogCategory.Resource, "url:" + url); GameEntry.Http.SendData(url, OnInitCDNAssetBundleInfo, isGetData: true); }
/// <summary> /// 加载自定义shader /// </summary> private void LoadShader() { GameEntry.Resource.ResourceLoaderManager.LoadAssetBundle(ConstDefine.CusShaderAssetBundlePath, onComplete: (AssetBundle bundle) => { bundle.LoadAllAssets(); Shader.WarmupAllShaders(); GameEntry.Log(LogCategory.Normal, "加载资源包中的自定义shader完毕"); GameEntry.Procedure.ChangeState(ProcedureState.LogOn); }); }
private void OnLoadLuaDataTableComplete(object param) { GameEntry.Log(LogCategory.Normal, "加载Lua表格完毕"); #if !DISABLE_ASSETBUNDLE //ab包模式下,先加载shader LoadShader(); #else GameEntry.Procedure.ChangeState(ProcedureState.LogOn); #endif }
/// <summary> /// 从CDN加载资源信息 /// </summary> /// <param name="args"></param> private void OnLoadAssetInfoFromCDN(HttpCallBackArgs args) { if (!args.HasError) { InitAssetInfo(args.Data); } else { GameEntry.Log(LogCategory.Resource, args.Value); } }
public override void OnEnable() { base.OnEnable(); GameEntry.Log(LogCategory.Procedure, "OnEnable ProcedurePreload"); GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadOneDataTableComplete, OnLoadOneDataTableComplete); GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadDataTableComplete, OnLoadDataTableComplete); GameEntry.Event.CommonEvent.AddEventListener(SysEventId.LoadLuaDataTableComplete, OnLoadLuaDataTableComplete); GameEntry.Resource.InitAssetInfo(); GameEntry.DataTable.LoadDataTableAsync(); }
/// <summary> /// 初始化CDN资源包信息回调 /// </summary> /// <param name="args"></param> private void OnInitCDNAssetBundleInfo(HttpCallBackArgs args) { if (!args.HasError) { m_CDNVersionDic = GetAssetBundleVersionList(args.Data, ref m_CDNVersion); GameEntry.Log(LogCategory.Resource, "cdn资源包总数" + m_CDNVersionDic.Count); CheckVersionFileExistsInLocal(); } else { GameEntry.Log(LogCategory.Resource, args.Value); } }
/// <summary> /// 请求服务器 /// </summary> /// <param name="data"></param> /// <returns></returns> private IEnumerator Request(UnityWebRequest data) { yield return(data.SendWebRequest()); IsBusy = false; if (data.isHttpError || data.isNetworkError) { if (m_CallBack != null) { m_CallBackArgs.HasError = true; m_CallBackArgs.Value = data.error; if (!m_isGetData) { #if DEBUG_LOG_PROTO Debug.Log("打印Http接收数据"); #endif GameEntry.Log(LogCategory.Proto, "<color=#00eaff>接收消息:</color><color=#00ff9c>" + data.url + "</color>"); GameEntry.Log(LogCategory.Proto, "<color=#c5e1dc>==>>" + JsonUtility.ToJson(m_CallBackArgs) + "</color>"); } m_CallBack(m_CallBackArgs); } } else { if (m_CallBack != null) { m_CallBackArgs.HasError = false; m_CallBackArgs.Value = data.downloadHandler.text; if (!m_isGetData) { #if DEBUG_LOG_PROTO Debug.Log("打印Http接收数据"); #endif GameEntry.Log(LogCategory.Proto, "<color=#00eaff>接收消息:</color><color=#00ff9c>" + data.url + "</color>"); GameEntry.Log(LogCategory.Proto, "<color=#c5e1dc>==>>" + JsonUtility.ToJson(m_CallBackArgs) + "</color>"); } m_CallBackArgs.Data = data.downloadHandler.data; m_CallBack(m_CallBackArgs); } } data.Dispose(); data = null; //支持多个HttpRoutine,结束之后回池 GameEntry.Pool.EnqueueClassObject(this); }
/// <summary> /// 初始化只读区资源信息 /// </summary> public void InitStreamingAssetsBundleInfo() { GameEntry.Log(LogCategory.Resource, "InitStreamingAssetsBundleInfo"); ReadStreamingAssetsBundle("VersionFile.bytes", (byte[] buffer) => { if (buffer == null) { InitCDNAssetBundleInfo(); } else { m_IsExistsStreamingAssetBundleInfo = true; m_StreamingAssetsVersionDic = GetAssetBundleVersionList(buffer, ref m_StreamingAssetsVersion); InitCDNAssetBundleInfo(); } }); }
public override void OnEnable() { base.OnEnable(); GameEntry.Log(LogCategory.Procedure, "OnEnable ProcedureLaunch"); //访问账号服务器部分,等数据库搭建起来,再测试,暂时当做通过验证 GameEntry.Data.SysDataManager.CurrChannelConfig.ChannelId = 0; GameEntry.Data.SysDataManager.CurrChannelConfig.InnerVersion = 1001; GameEntry.Data.SysDataManager.CurrChannelConfig.SourceUrl = "http://192.168.0.108:8081/"; GameEntry.Data.SysDataManager.CurrChannelConfig.SourceVersion = "1.0.7"; Debug.Log(GameEntry.Data.SysDataManager.CurrChannelConfig.RealSourceUrl); //string url = GameEntry.Http.RealWebUrl + "/api/accountlaunch"; //GameEntry.Http.SendData(url, WebGetCallBack); //Dictionary<string, object> dic = GameEntry.Pool.DequeueClassObject<Dictionary<string,object>>(); //dic["ChannelId"] = 0; //dic["InnerVersion"] = 1001; //GameEntry.Http.SendData(url, WebPostCallBack, true, dic); }
/// <summary> /// 更新资源包请求 /// </summary> private void UpdateAssetBundleCreateRequest() { if (m_CurrAssetBundleCreateRequest != null) { if (m_CurrAssetBundleCreateRequest.isDone) { AssetBundle assetBundle = m_CurrAssetBundleCreateRequest.assetBundle; if (assetBundle != null) { GameEntry.Log(LogCategory.Resource, string.Format("资源包=>{0} 加载完毕", m_CurrAssetBundleInfo.AssetBundleName)); Reset(); if (OnLoadAssetBundleComplete != null) { OnLoadAssetBundleComplete(assetBundle); } } else { GameEntry.LogError("资源包=>{0} 加载失败", m_CurrAssetBundleInfo.AssetBundleName); Reset(); if (OnLoadAssetBundleComplete != null) { OnLoadAssetBundleComplete(null); } } } else { //加载进度 if (OnAssetBundleCreateUpdate != null) { OnAssetBundleCreateUpdate(m_CurrAssetBundleCreateRequest.progress); } } } }
/// <summary> /// 更新资源请求 /// </summary> private void UpdateAssetBundleRequest() { if (m_CurrAssetBundleRequest != null) { if (m_CurrAssetBundleRequest.isDone) { UnityEngine.Object obj = m_CurrAssetBundleRequest.asset; if (obj != null) { GameEntry.Log(LogCategory.Resource, string.Format("资源=>{0} 加载完毕", obj.name)); Reset(); if (OnLoadAssetComplete != null) { OnLoadAssetComplete(obj); } } else { GameEntry.LogError("资源包=>{0} 加载失败", "???"); Reset(); if (OnLoadAssetComplete != null) { OnLoadAssetComplete(null); } } } else { //加载进度 if (OnAssetUpdate != null) { OnAssetUpdate(m_CurrAssetBundleRequest.progress); } } } }
/// <summary> /// 检查可写区版本文件是否存在 /// </summary> private void CheckVersionFileExistsInLocal() { GameEntry.Log(LogCategory.Resource, "CheckVersionFileExistsInLocal"); if (LocalAssetManager.GetVersionFileExists()) { //可写区版本文件存在 //加载可写区资源包信息 InitLocalAssetBundleInfo(); } else { //可写区版本文件不存在 //判断只读区版本文件是否存在 if (m_IsExistsStreamingAssetBundleInfo) { //只读区版本文件存在 //将只读区版本文件初始化到可写区 InitVersionFileFormStreamingAssetsToLocal(); } CheckVersionChange(); } }
public override void OnLeave() { base.OnLeave(); GameEntry.Log(LogCategory.Procedure, "OnLeave ProcedureCheckVersion"); }
public override void OnLeave() { GameEntry.Log(LogCategory.Procedure, "OnLeave ProcedureLogOn"); }
private void OnLoadLuaDataTableComplete(object param) { GameEntry.Log(LogCategory.Normal, "加载Lua表格完毕"); GameEntry.Procedure.ChangeState(ProcedureState.LogOn); }
/// <summary> /// 初始化可写区资源包信息 /// </summary> private void InitLocalAssetBundleInfo() { GameEntry.Log(LogCategory.Resource, "InitLocalAssetBundleInfo"); m_LocalAssetsVersionDic = LocalAssetManager.GetAssetBundleVersionList(ref m_LocalAssetsVersion); CheckVersionChange(); }