From 10deef53cfcbf8e21c14490b188b212c5d90c1aa Mon Sep 17 00:00:00 2001 From: gaoxin Date: Mon, 31 May 2021 21:36:05 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=95=8C=E9=9D=A2=E8=83=8C=E6=99=AF=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/GameInit/UpdatePanel.cs | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/GameInit/UpdatePanel.cs b/Assets/Scripts/GameInit/UpdatePanel.cs index a21ddcd880..cc4aca00c2 100644 --- a/Assets/Scripts/GameInit/UpdatePanel.cs +++ b/Assets/Scripts/GameInit/UpdatePanel.cs @@ -28,6 +28,7 @@ namespace GameLogic [SerializeField] UpdateMsgBox msgBox; + AssetBundle bundle; void Awake() { msgBox.gameObject.SetActive(false); @@ -41,7 +42,29 @@ namespace GameLogic string updatePanelBg = ConfigManager.Instance.GetConfigInfo("Setting.UPDATE_PANEL_BG.value"); if (updatePanelBg != null) { - this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent().sprite = App.ResMgr.LoadSpriteAsset(updatePanelBg); + if (AppConst.bundleMode) + { + string path = AppConst.PersistentDataPath + "lz4/bg/loading/" + updatePanelBg + ".unity3d"; + if (!File.Exists(path)) + { + path = AppConst.StreamPath + "lz4/bg/loading/" + updatePanelBg + ".unity3d"; + } + bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength); + if (bundle == null) + { + XDebug.Log.error(string.Format("{0} 不存在,请检查", path)); + return; + } + this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent().sprite = bundle.LoadAsset(updatePanelBg); + } + else + { +#if UNITY_EDITOR + string path = AppConst.GameResPath + "/BG/Loading/" + updatePanelBg + ".jpg"; + Sprite sp = UnityEditor.AssetDatabase.LoadAssetAtPath(path); + this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent().sprite = sp; +#endif + } } } private void OnDestroy() @@ -49,7 +72,8 @@ namespace GameLogic string updatePanelBg = ConfigManager.Instance.GetConfigInfo("Setting.UPDATE_PANEL_BG.value"); if (updatePanelBg != null) { - App.ResMgr.UnLoadAsset(updatePanelBg); + if (bundle != null) bundle.Unload(true); + bundle = null; } }