【更新】更新界面背景加载方式修改

dev_chengFeng
gaoxin 2021-05-31 21:36:05 +08:00
parent 598b92f288
commit 10deef53cf
1 changed files with 26 additions and 2 deletions

View File

@ -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<Image>().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<Image>().sprite = bundle.LoadAsset<Sprite>(updatePanelBg);
}
else
{
#if UNITY_EDITOR
string path = AppConst.GameResPath + "/BG/Loading/" + updatePanelBg + ".jpg";
Sprite sp = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>(path);
this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent<Image>().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;
}
}